print len(lons_out), ' obs after thinning' # transform lons and lats to map coordinates. x, y = m(array(lons_out) / d2r, array(lats_out) / d2r) # find just those points in map region. xx = [] yy = [] for xi, yi in zip(x, y): if (xi > m.llcrnrx and xi < m.urcrnrx) and (yi > m.llcrnry and yi < m.urcrnry): xx.append(xi) yy.append(yi) # plot them as filled circles on the map. # first, create figure with same aspect ratio as map. fig = m.createfigure() # background color will be used for 'wet' areas. fig.add_axes([0.1, 0.1, 0.8, 0.8], axisbg='aqua') # use zorder=10 to make sure markers are drawn last. # (otherwise they are covered up when continents are filled) m.scatter(xx, yy, marker='o', c='k', s=25, zorder=10) # draw coasts and fill continents. m.drawcoastlines(linewidth=0.5) m.fillcontinents(color='coral') # draw parallels and meridians. delat = 20. circles = arange(0.,90.,delat).tolist()+\ arange(-delat,-90,-delat).tolist() m.drawparallels(circles) delon = 45. meridians = arange(0, 360, delon)
mapfile = sys.argv[1]+'.lonlatT' lonfile = sys.argv[1]+'.lon' latfile = sys.argv[1]+'.lat' color_num = int(sys.argv[2]) # load data map=array(load(mapfile)) lons=array(load(lonfile)) lats=array(load(latfile)) map,lons = shiftgrid(180.,map,lons,start=False) # Mollweide projection m1 = Basemap(projection='moll',lon_0=0.5*(lons[0]+lons[-1])) lons, lats = meshgrid(lons, lats) fig1 = m1.createfigure() x, y = m1(lons, lats) cs = m1.contourf(x,y,map,color_num,cmap=cm.jet) m1.drawparallels(arange(-90.,90.,20.),labels=[1,0,0,0]) m1.drawmeridians(arange(0.,420.,30.),labels=[0,0,0,1]) #title('Moll. proj:'+ sys.argv[1]) title(r'$>3\sigma\/ detections\/ composite\/ map:\/ skewness$') #title(r'$>3\sigma\/ detections\/ composite\/ map:\/ kurtosis$') colorbar(); savefig(sys.argv[1]+'-moll.png'); #savefig(sys.argv[1]+'-moll.eps') savefig(sys.argv[1]+'-moll.jpg'); #show()
nob = nob + 1 print len(lons_out), ' obs after thinning' # transform lons and lats to map coordinates. x,y = m(array(lons_out)/d2r, array(lats_out)/d2r) # find just those points in map region. xx=[] yy=[] for xi,yi in zip(x,y): if (xi>m.llcrnrx and xi<m.urcrnrx) and (yi>m.llcrnry and yi<m.urcrnry): xx.append(xi) yy.append(yi) # plot them as filled circles on the map. # first, create figure with same aspect ratio as map. fig=m.createfigure() # background color will be used for 'wet' areas. fig.add_axes([0.1,0.1,0.8,0.8],axisbg='aqua') # use zorder=10 to make sure markers are drawn last. # (otherwise they are covered up when continents are filled) m.scatter(xx,yy,marker='o',c='k',s=25,zorder=10) # draw coasts and fill continents. m.drawcoastlines(linewidth=0.5) m.fillcontinents(color='coral') # draw parallels and meridians. delat = 20. circles = arange(0.,90.,delat).tolist()+\ arange(-delat,-90,-delat).tolist() m.drawparallels(circles) delon = 45. meridians = arange(0,360,delon)
from matplotlib.toolkits.basemap import Basemap from pylab import * # read in topo data (on a regular lat/lon grid) etopo = array(load('etopo20data.gz'),'d') lons = array(load('etopo20lons.gz'),'d') lats = array(load('etopo20lats.gz'),'d') # create Basemap instance for Orthographic (satellite view) projection. lon_0 = float(raw_input('enter reference longitude (lon_0):')) lat_0 = float(raw_input('enter reference latitude (lat_0):')) fillcont = int(raw_input('fill continents? (1 for yes, 0 for no):')) m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0) # compute native map projection coordinates for lat/lon grid. lons, lats = meshgrid(lons, lats) x,y = m(lons,lats) # create figure with same aspect ratio as map. fig=m.createfigure().add_axes([0.05,0.05,0.9,0.9]) # make filled contour plot. cs = m.contourf(x,y,etopo,30,cmap=cm.jet) # draw coastlines. m.drawcoastlines() # draw a line around the map region. m.drawmapboundary() if fillcont: m.fillcontinents() # draw parallels and meridians. m.drawparallels(arange(-90.,120.,30.)) m.drawmeridians(arange(0.,420.,60.)) title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0,lat_0)) show()
#palette.set_bad('aqua', 1.0) # plot image over map with imshow. #im = m.imshow(topodatm,palette,norm=colors.normalize(vmin=0.0,vmax=3000.0,clip=False)) #a=axes() #subplots_adjust(left=None,right=None,top=None,bottom=None,wspace=0,hspace=0) # Mollweide projection lons, lats = meshgrid(lons, lats) #m1 = Basemap(projection='moll',lon_0=0.5*(lons[0]+lons[-1])) m1 = Basemap(projection='moll', lon_0=0) delta = (maxv - minv) / color_num levels = arange(minv - 1 * delta, maxv + 1 * delta, delta) print(levels) fig = m1.createfigure() subplots_adjust(left=0, right=.99, top=0.99, bottom=0.1, wspace=0, hspace=0) x, y = m1(lons, lats) fig = figure(figsize=(12, 6), dpi=dpires) #fig=figure(figsize=(4,2), dpi=dpires) #print dpires ax = gca() #cs = m1.contourf(x,y,mapM,color_num,cmap=cm.jet) #cs = m1.contourf(x,y,mapM,color_num,cmap=palette, norm = matplotlib.colors.normalize(vmin=minv, vmax=maxv, clip=False) ) #cs = m1.contourf(x,y,mapM,colors=None, cmap=palette, norm = matplotlib.colors.normalize(vmin=minv, vmax=maxv, clip=False) ) #cs = m1.contourf(x,y,mapM, color_num, cmap=palette, norm = matplotlib.colors.normalize(vmin=minv, vmax=maxv, clip=False), extend='min' ) #cs = m1.contourf(x,y,mapM, levels, cmap=palette, norm = matplotlib.colors.normalize(vmin=minv, vmax=maxv, clip=False) ) cs = m1.contourf(x, y, mapM, levels, cmap=palette)
from matplotlib.toolkits.basemap import Basemap import pylab as p # set up orthographic map projection with # perspective of satellite looking down at 50N, 100W. # use low resolution coastlines. map = Basemap(projection='ortho', lat_0=50, lon_0=-100, resolution='l') # set up figure. fig = map.createfigure() # draw coastlines, country boundaries, fill continents. map.drawcoastlines() map.drawcountries() map.fillcontinents(color='coral') # draw the edge of the map projection region (the projection limb) map.drawmapboundary() # draw lat/lon grid lines every 30 degrees. map.drawmeridians(p.arange(0, 360, 30)) map.drawparallels(p.arange(-90, 90, 30)) # lat/lon coordinates of five cities. lats = [40.02, 34.00, 38.55, 48.25, 17.29] lons = [-105.16, -119.40, -77.00, -114.21, -88.10] cities = [ 'Boulder, CO', 'Santa Cruz, CA', 'Washington, DC', 'Whitefish, MT', 'Belize City, Belize' ] # compute the native map projection coordinates for cities. x, y = map(lons, lats) # plot filled circles at the locations of the cities. map.plot(x, y, 'bo') # plot the names of those five cities. for name, xpt, ypt in zip(cities, x, y): p.text(xpt + 50000, ypt + 50000, name)
from matplotlib.toolkits.basemap import Basemap from pylab import * # read in topo data (on a regular lat/lon grid) etopo = array(load('etopo20data.gz'), 'd') lons = array(load('etopo20lons.gz'), 'd') lats = array(load('etopo20lats.gz'), 'd') # create Basemap instance for Orthographic (satellite view) projection. lon_0 = float(raw_input('enter reference longitude (lon_0):')) lat_0 = float(raw_input('enter reference latitude (lat_0):')) fillcont = int(raw_input('fill continents? (1 for yes, 0 for no):')) m = Basemap(projection='ortho', lon_0=lon_0, lat_0=lat_0) # compute native map projection coordinates for lat/lon grid. lons, lats = meshgrid(lons, lats) x, y = m(lons, lats) # create figure with same aspect ratio as map. fig = m.createfigure().add_axes([0.05, 0.05, 0.9, 0.9]) # make filled contour plot. cs = m.contourf(x, y, etopo, 30, cmap=cm.jet) # draw coastlines. m.drawcoastlines() # draw a line around the map region. m.drawmapboundary() if fillcont: m.fillcontinents() # draw parallels and meridians. m.drawparallels(arange(-90., 120., 30.)) m.drawmeridians(arange(0., 420., 60.)) title('Orthographic Map Centered on Lon=%s, Lat=%s' % (lon_0, lat_0)) show()
latminout = 22.0 llcrnrlon = -125.0 urcrnrlon = -60.0 standardpar = 50.0 centerlon=-105. # create Basemap instance for Lambert Conformal Conic projection. m = Basemap(llcrnrlon=llcrnrlon,llcrnrlat=llcrnrlat, urcrnrlon=urcrnrlon,urcrnrlat=urcrnrlat, rsphere=6371200., resolution='l',area_thresh=5000.,projection='lcc', lat_1=standardpar,lon_0=centerlon) x, y = m(lons, lats) # create figure. # mult ysize by 3/2 to take into account there will # be three rows and two columns. fig=m.createfigure(figsize=(8,(3./2.)*8)) yoffset = (m.urcrnry-m.llcrnry)/30. for npanel,fcsthr in enumerate(arange(0,72,12)): nt = fcsthrs.index(fcsthr) ax = fig.add_subplot(320+npanel+1) cs = m.contour(x,y,t2m[nt,:,:],clevs,colors='k') cs = m.contourf(x,y,t2m[nt,:,:],clevs,cmap=cm.jet) m.drawcoastlines() m.drawstates() m.drawcountries() m.drawparallels(arange(25,75,20),labels=[1,0,0,0],fontsize=8,fontstyle='oblique') m.drawmeridians(arange(-140,0,20),labels=[0,0,0,1],fontsize=8,yoffset=yoffset,fontstyle='oblique') # panel title title(repr(fcsthr)+'-h forecast valid '+verifdates[nt],fontsize=12) # figure title figtext(0.5,0.95,u"2-m temp (\N{DEGREE SIGN}K) forecasts from %s"%verifdates[0],
from matplotlib.toolkits.basemap import Basemap import pylab as p # set up orthographic map projection with # perspective of satellite looking down at 50N, 100W. # use low resolution coastlines. map = Basemap(projection='ortho',lat_0=50,lon_0=-100,resolution='l') # set up figure. fig=map.createfigure() # draw coastlines, country boundaries, fill continents. map.drawcoastlines() map.drawcountries() map.fillcontinents(color='coral') # draw the edge of the map projection region (the projection limb) map.drawmapboundary() # draw lat/lon grid lines every 30 degrees. map.drawmeridians(p.arange(0,360,30)) map.drawparallels(p.arange(-90,90,30)) # lat/lon coordinates of five cities. lats=[40.02,34.00,38.55,48.25,17.29] lons=[-105.16,-119.40,-77.00,-114.21,-88.10] cities=['Boulder, CO','Santa Cruz, CA', 'Washington, DC','Whitefish, MT','Belize City, Belize'] # compute the native map projection coordinates for cities. x,y = map(lons,lats) # plot filled circles at the locations of the cities. map.plot(x,y,'bo') # plot the names of those five cities. for name,xpt,ypt in zip(cities,x,y): p.text(xpt+50000,ypt+50000,name) # make up some data on a regular lat/lon grid. nlats = 73; nlons = 145; delta = 2.*p.pi/(nlons-1)
# create Basemap instance for Lambert Conformal Conic projection. m = Basemap(llcrnrlon=llcrnrlon, llcrnrlat=llcrnrlat, urcrnrlon=urcrnrlon, urcrnrlat=urcrnrlat, rsphere=6371200., resolution='l', area_thresh=5000., projection='lcc', lat_1=standardpar, lon_0=centerlon) x, y = m(lons, lats) # create figure. # mult ysize by 3/2 to take into account there will # be three rows and two columns. fig = m.createfigure(figsize=(8, (3. / 2.) * 8)) yoffset = (m.urcrnry - m.llcrnry) / 30. for npanel, fcsthr in enumerate(arange(0, 72, 12)): nt = fcsthrs.index(fcsthr) ax = fig.add_subplot(320 + npanel + 1) cs = m.contour(x, y, t2m[nt, :, :], clevs, colors='k') cs = m.contourf(x, y, t2m[nt, :, :], clevs, cmap=cm.jet) m.drawcoastlines() m.drawstates() m.drawcountries() m.drawparallels(arange(25, 75, 20), labels=[1, 0, 0, 0], fontsize=8, fontstyle='oblique') m.drawmeridians(arange(-140, 0, 20), labels=[0, 0, 0, 1],