minlon=min(lon) maxlat=max(lat) minlat=min(lat) #make sure the picture can show lat and lon clearly if maxlat-minlat<=0.1: maxlat=maxlat+0.01 minlat=minlat-0.01 if maxlon-minlon<=0.1: maxlon=maxlon+0.01 minlon=minlon-0.01 gbox=[minlon-1.0,maxlon+1.0, minlat-0.03, maxlat+0.03] # get edge for get sst for x in range(num): ask_input=num2date(datetime_wanted) #get time for getsst #plt.title(str(num2date(datetime_wanted).strftime("%d-%b-%Y %H"))+'h') plot_getsst(ask_input,utc,gbox) lat_wanted=lat[-1] lon_wanted=lon[-1] #find wanted point lat,lon #plt.plot(lon_wanted,lat_wanted,'.',markersize=30,color='m',label='end') plt.plot(np.reshape(lon,np.size(lon)),np.reshape(lat,np.size(lat)),linewidth=3,color='black') #plt.plot(lon[0],lat[0],'.',markersize=20,color='g',label='start') # start time plt.annotate('start',xy=(lon[0],lat[0]),xytext=(lon[0]+(maxlon-minlon)/10,lat[0]+(maxlat-minlat)/10),color='white',arrowprops=dict(facecolor='white',frac=0.3, shrink=0.05)) plt.annotate('end',xy=(lon[-1],lat[-1]),xytext=(lon[-1]+(maxlon-minlon)/10,lat[-1]-(maxlat-minlat)/5),color='white',arrowprops=dict(facecolor='white',frac=0.3, shrink=0.05)) plt.title('Drifter '+driftnumber+' and '+ask_input.strftime('%d %b %Y')+' SST') basemap_standard([int(minlat),np.ceil(maxlat)],[int(minlon-1.5),np.ceil(maxlon)+1.0],2.0) #overrides xlim and ylims set previously plt.show()
#get FVCOM depths url = 'http://www.smast.umassd.edu:8080/thredds/dodsC/fvcom/hindcasts/30yr_gom3?lon,lat,h,nv' nc = netCDF4.Dataset(url) lat = nc.variables['lat'][:] 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
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: #print df.index[i],lat[i],lon[i]
ask_input = num2date(datetime_wanted) #get time for getsst #plt.title(str(num2date(datetime_wanted).strftime("%d-%b-%Y %H"))+'h') plot_getsst(ask_input, utc, gbox) lat_wanted = lat[-1] lon_wanted = lon[-1] #find wanted point lat,lon #plt.plot(lon_wanted,lat_wanted,'.',markersize=30,color='m',label='end') plt.plot(np.reshape(lon, np.size(lon)), np.reshape(lat, np.size(lat)), linewidth=3, color='black') #plt.plot(lon[0],lat[0],'.',markersize=20,color='g',label='start') # start time plt.annotate('start', xy=(lon[0], lat[0]), xytext=(lon[0] + (maxlon - minlon) / 10, lat[0] + (maxlat - minlat) / 10), color='white', arrowprops=dict(facecolor='white', frac=0.3, shrink=0.05)) plt.annotate('end', xy=(lon[-1], lat[-1]), xytext=(lon[-1] + (maxlon - minlon) / 10, lat[-1] - (maxlat - minlat) / 5), color='white', arrowprops=dict(facecolor='white', frac=0.3, shrink=0.05)) plt.title('Drifter ' + driftnumber + ' and ' + ask_input.strftime('%d %b %Y') + ' SST') basemap_standard([int(minlat), np.ceil(maxlat)], [int(minlon - 1.5), np.ceil(maxlon) + 1.0], 2.0) #overrides xlim and ylims set previously plt.show()
import sys sys.path.append("../modules") import basemap as bm import matplotlib.pyplot as plt # the following three lines are needed to later place the figure windows on the screen import matplotlib matplotlib.use("wx") import pylab # use the standard Basemap plt.figure(1, figsize=(5, 4)) # makes figure less than the defaul 8x6 inches bm.basemap_standard([42.0, 43.0], [-71.0, -70.0], [0.5]) # always make this last argument a list in brackets # 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
import sys sys.path.append("../modules") import basemap as bm import matplotlib.pyplot as plt import pylab from pylab import ginput import numpy as np # extract coastline and bathymetry using pydap plt.figure(1,figsize=(10,8)) #bm.basemap_detail([41.,43.5],[-72.,-69.0],True,True,0.5) #bm.basemap_detail([41.0,43.5],[-72.,-69.0],True,False) bm.basemap_standard([41.0,43.5],[-72.,-69.0], [2]) plt.title('PIs (white) and Partners (black)',fontsize=18) plt.show() sites=['GOMI','NESS','WHOI','SSC','SSNSC','WHSTEP','NEFSC','CCS','NGSS','CMHS','NEAq','SEA','SBNMS','WBWS','CSWA'] nums=len(sites) print 'There are '+str(nums)+'sites' '''pts=ginput(nums, timeout=120) x=map(lambda x: x[0],pts) # map applies the function passed as y=map(lambda x: x[1],pts) # first parameter to each e np.save('sites',[x,y]) ''' p=np.load('sites.npy') x=p[0] y=p[1] for k in range(len(x)): plt.plot(x[k], y[k],'.',color='w') plt.annotate(sites[k],xy=(x[k],y[k]),xytext=(x[k]+.3,y[k]),arrowprops=dict(facecolor='black', shrink=0.05)) plt.show()