def InvokeMap(coastfile='/media/sda4/map-data/aust-coast-noaa-2000000-1.dat', lllon=80, urlon=166, lllat=-47, urlat=-9, draw_map=True): global PYLIB_PATH map = Basemap(projection='cyl', llcrnrlon=lllon, urcrnrlon=urlon, llcrnrlat=lllat, urcrnrlat=urlat, #lat_ts=-35, lat_0=-35, lon_0=120, resolution='l', area_thresh=1000.) try: coast = p.load(coastfile) coast = p.load(coastfile) coast_x,coast_y = map(coast[:,0],coast[:,1]) p.plot(coast_x,coast_y,color='black') except IOError: map.drawcoastlines() map.drawmapboundary() map.drawmeridians(p.arange(0,360,10),labels=[0,0,1,0]) map.drawparallels(p.arange(-90,0,10),labels=[1,0,0,0]) return map
def doit(): map = Basemap(projection='lcc', llcrnrlon=80, urcrnrlon=160, llcrnrlat=-50, urcrnrlat=-8, #lat_ts=-35, lat_0=-35, lon_0=120, resolution='c', area_thresh=1000.) p.clf() map.drawcoastlines() # map.drawcountries() # map.drawrivers() map.drawmeridians(p.arange(0,360,10),labels=[0,0,1,0]) map.drawparallels(p.arange(-90,0,10),labels=[1,0,0,0]) traj=p.load('example_traj.dat') coast=p.load('/media/sda4/map-data/aust-coast-noaa-2000000-1.dat') traj_x,traj_y = map(traj[:,1],traj[:,0]) # coast_x,coast_y = map(coast[:,0],coast[:,1]) p.plot(traj_x,traj_y) p.plot(coast_x,coast_y,color='black') map.drawmapboundary() p.show() return map
lons = load('etopo20lons.gz') lats = load('etopo20lats.gz') # create figure. fig = Figure() canvas = FigureCanvas(fig) # create axes instance, leaving room for colorbar at bottom. ax = fig.add_axes([0.125,0.175,0.75,0.75]) # create Basemap instance for Robinson projection. # set 'ax' keyword so pylab won't be imported. m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1]),ax=ax) # make filled contour plot. x, y = m(*meshgrid(lons, lats)) cs = m.contourf(x,y,etopo,30,cmap=cm.jet) # draw coastlines. m.drawcoastlines() # draw a line around the map region. m.drawmapboundary() # draw parallels and meridians. m.drawparallels(nx.arange(-60.,90.,30.),labels=[1,0,0,0],fontsize=10) m.drawmeridians(nx.arange(0.,420.,60.),labels=[0,0,0,1],fontsize=10) # add a title. ax.set_title('Robinson Projection') # add a colorbar. l,b,w,h = ax.get_position() cax = fig.add_axes([l, b-0.1, w, 0.03],frameon=False) # setup colorbar axes fig.colorbar(cs, cax=cax, orientation='horizontal',ticks=cs.levels[::3]) # save image (width 800 pixels with dpi=100 and fig width 8 inches). canvas.print_figure('simpletest',dpi=100) # done. print 'image saved in simpletest.png'
def plot_track(rlon, rlat=None, m=None, **keywords): show_lat = 1 if ('show_lat' in keywords): show_lat = keywords['show_lat'] show_lon = 1 if ('show_lon' in keywords): show_lon = keywords['show_lon'] if (m == None): map_proj = 'cyl' if ('map_proj' in keywords): map_proj = keywords['map_proj'] lat_0 = 0.0 if ('lat_0' in keywords): lat_0 = keywords['lat_0'] minlat = -90.0 maxlat = 90.0 if ('minlat' in keywords): minlat = keywords['minlat'] if ('maxlat' in keywords): maxlat = keywords['maxlat'] minlon = -180 maxlon = 180.0 if ('minlon' in keywords): minlon = keywords['minlon'] if ('maxlon' in keywords): maxlon = keywords['maxlon'] lon_0 = 0 if ('lon_0' in keywords): lon_0 = keywords['lon_0'] boundinglat = 45 if ('boundinglat' in keywords): boundinglat = keywords['boundinglat'] if (map_proj == 'npstere' or map_proj == 'spstere'): m = Basemap(projection=map_proj, lon_0=lon_0, boundinglat=boundinglat) elif (map_proj == 'ortho'): m = Basemap(projection=map_proj, lon_0=lon_0, lat_0=lat_0) else: m=Basemap(llcrnrlon=minlon, llcrnrlat=minlat, \ urcrnrlon=maxlon, urcrnrlat=maxlat,projection=map_proj, lon_0=lon_0, lat_0=lat_0) if (show_lat == 1): m.drawparallels(arange(minlat, maxlat + 30.0, 30.), labels=[1, 0, 0, 0]) if (show_lon == 1): m.drawmeridians(arange(minlon, maxlon + 60, 60.), labels=[0, 0, 0, 1]) sgn = '+' if ('sgn' in keywords): sgn = keywords['sgn'] if ('color' in keywords): lcolor = keywords['color'] if (len(rlon) < 100): m.plot(rlon, rlat, sgn, color=lcolor, markersize=11) else: m.plot(rlon, rlat, sgn, color=lcolor, markersize=6) else: m.plot(rlon, rlat, sgn) m.drawcoastlines(color='w', linewidth=0.5) m.drawmapboundary() # m.drawcountries(color='k', linewidth=0.5) if ('title' in keywords): stitle = keywords['title'] title(stitle) return m
def plot_map(data, rlon=None, rlat=None, use_pcolor=0, **keywords): """ display the data in a map keywords: dict which can include the following keywords minv=0.0, maxv=0.0, dv=0.0, show_map=0, map_proj='cyl', show_lat=0, show_lon=0, lat_0=0.0, lon_0=0.0, minlat=-90.0, maxlat=90.0, minlon=0.0, maxlon=360.0, use_log=0, level=level """ minv = 0.0 if ('minv' in keywords): minv = keywords['minv'] maxv = 0.0 if ('maxv' in keywords): maxv = keywords['maxv'] dv = 0.0 if ('dv' in keywords): dv = keywords['dv'] if ('dv' in keywords): dv = keywords['dv'] if (maxv > minv): rlvl = arange(minv, maxv + dv, dv) rlvl[0] = -999.0 rlvl[size(rlvl) - 1] = 999. stitle = "" add_str = "" if ('title' in keywords): add_str = keywords['title'] add_str = add_str.strip() stitle = stitle + ' ' + add_str if ('unit' in keywords): add_str = keywords['unit'] add_str = add_str.strip() stitle = stitle + '(' + add_str + ')' cbar_vert = 1 if ('cbar_vert' in keywords): cbar_vert = keywords['cbar_vert'] if (cbar_vert == 1): orientation = 'vertical' else: orientation = 'horizontal' show_lat = 1 if ('show_lat' in keywords): show_lat = keywords['show_lat'] show_lon = 1 if ('show_lon' in keywords): show_lon = keywords['show_lon'] nlon, nlat = shape(data) vals = array(data) map_proj = 'cyl' if ('map_proj' in keywords): map_proj = keywords['map_proj'] lat_0 = 0.0 if ('lat_0' in keywords): lat_0 = keywords['lat_0'] minlat = -90.0 maxlat = 90.0 if ('minlat' in keywords): minlat = keywords['minlat'] if ('maxlat' in keywords): maxlat = keywords['maxlat'] if (rlat == None): dlat = (maxlat - minlat) / nlat rlat = arange(minlat, maxlat, dlat) minlon = -180 maxlon = 180.0 if ('minlon' in keywords): minlon = keywords['minlon'] if ('maxlon' in keywords): maxlon = keywords['maxlon'] if (rlon == None): dlon = (maxlon - minlon) / nlon rlon = arange(minlon, maxlon, dlon) lon_0 = 0 do_bdr = 0 if ('do_bdr' in keywords): do_bdr = keywords['do_bdr'] if ('lon_0' in keywords): lon_0 = keywords['lon_0'] boundinglat = 45 if ('boundinglat' in keywords): boundinglat = keywords['boundinglat'] if (map_proj == 'npstere' or map_proj == 'spstere'): m = Basemap(projection=map_proj, lon_0=lon_0, boundinglat=boundinglat) elif (map_proj == 'ortho'): m = Basemap(projection=map_proj, lon_0=lon_0, lat_0=lat_0) else: if (maxlon - minlon > 180): m=Basemap(llcrnrlon=minlon, llcrnrlat=minlat, \ urcrnrlon=maxlon, urcrnrlat=maxlat,projection=map_proj, lon_0=lon_0, lat_0=lat_0, resolution='l') else: m=Basemap(llcrnrlon=minlon, llcrnrlat=minlat, \ urcrnrlon=maxlon, urcrnrlat=maxlat,projection=map_proj, lon_0=lon_0, lat_0=lat_0, resolution='i') if (rlon[-1] < rlon[0] + 360.0): rlon = resize(rlon, nlon + 1) rlon[-1] = rlon[0] + 360.0 vals = squeeze(vals) vals = resize(vals, [nlon + 1, nlat]) x, y = m(*meshgrid(rlon, rlat)) cmap = cm.Paired if ('cmap' in keywords): print 'cmap included' cmap = keywords['cmap'] m.drawcoastlines(color='k', linewidth=0.5) if (maxv > minv): if (use_pcolor == 1): cs0 = m.pcolormesh(x, y, transpose(vals), shading='flat', vmin=minv, vmax=maxv, cmap=cmap) # cs0=m.imshow(x, y, transpose(vals), shading='flat', vmin=minv, vmax=maxv, cmap=cmap) else: cs0 = m.contourf(x, y, transpose(vals), rlvl, cmap=cmap) else: if (use_pcolor == 1): cs0 = m.pcolor(x, y, transpose(vals), shading='flat', cmap=cmap) else: cs0 = m.contourf(x, y, transpose(vals), cmap=cmap) # info(m.drawcoastlines) # m.drawcountries(color=white) m.drawmapboundary() if (show_lat == 1): if (maxlat - minlat >= 90): m.drawparallels(arange(minlat, maxlat + 30.0, 30.), labels=[1, 0, 0, 0], color='grey') else: m.drawparallels(arange(minlat, maxlat + 5.0, 5.), labels=[1, 0, 0, 0], color='grey') if (show_lon == 1): if (maxlon - minlon >= 180): m.drawmeridians(arange(minlon, maxlon + 60, 60.), labels=[0, 0, 0, 1], color='grey') else: m.drawmeridians(arange(minlon, maxlon + 10, 10.), labels=[0, 0, 0, 1], color='grey') title(stitle) show_colorbar = 1 if ('cb' in keywords): show_colorbar = keywords['cb'] if (show_colorbar == 1): colorbar(orientation=orientation, extend='both') if (do_bdr == 1): lvl = arange(max(vals.flat)) print shape(x), shape(y), shape(vals) # cs2=m.contour(x[0:-1,:], y[0:-1,:], transpose(vals), lvl, colors='k', linewidth=0.5) return m
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 Robinson projection. m = Basemap(projection='robin', lon_0=0.5 * (lons[0] + lons[-1])) # create figure with same aspect ratio as map. fig = m.createfigure() # make filled contour plot. x, y = m(*meshgrid(lons, lats)) cs = m.contourf(x, y, etopo, 30, cmap=cm.jet) # draw coastlines. m.drawcoastlines() # draw a line around the map region. m.drawmapboundary() # draw parallels and meridians. m.drawparallels(arange(-60., 90., 30.), labels=[1, 0, 0, 0]) m.drawmeridians(arange(0., 420., 60.), labels=[0, 0, 0, 1]) # add a title. title('Robinson Projection') show()
def plot_track(rlon, rlat=None, m=None, **keywords): show_lat = 1 if ('show_lat' in keywords): show_lat = keywords['show_lat'] show_lon = 1 if ('show_lon' in keywords): show_lon = keywords['show_lon'] if (m is None): map_proj = 'cyl' if ('map_proj' in keywords): map_proj = keywords['map_proj'] lat_0 = 0.0 if ('lat_0' in keywords): lat_0 = keywords['lat_0'] minlat = -90.0 maxlat = 90.0 if ('minlat' in keywords): minlat = keywords['minlat'] if ('maxlat' in keywords): maxlat = keywords['maxlat'] minlon = -180 maxlon = 180.0 if ('minlon' in keywords): minlon = keywords['minlon'] if ('maxlon' in keywords): maxlon = keywords['maxlon'] lon_0 = 0 if ('lon_0' in keywords): lon_0 = keywords['lon_0'] boundinglat = 45 if ('boundinglat' in keywords): boundinglat = keywords['boundinglat'] if (map_proj == 'npstere' or map_proj == 'spstere'): m = Basemap(projection=map_proj, lon_0=lon_0, boundinglat=boundinglat) elif (map_proj == 'ortho'): m = Basemap(projection=map_proj, lon_0=lon_0, lat_0=lat_0) else: m = Basemap(llcrnrlon=minlon, llcrnrlat=minlat, urcrnrlon=maxlon, urcrnrlat=maxlat, projection=map_proj, lon_0=lon_0, lat_0=lat_0) if (show_lat == 1): m.drawparallels(arange(minlat, maxlat + 30.0, 30.), labels=[1, 0, 0, 0]) if (show_lon == 1): m.drawmeridians(arange(minlon, maxlon + 60, 60.), labels=[0, 0, 0, 1]) sgn = 'o' if ('sgn' in keywords): sgn = keywords['sgn'] if ('color' in keywords): print('I am here', size(rlon)) lcolor = keywords['color'] print(max(lcolor), min(lcolor)) if ('minv' in keywords): vmin = keywords['minv'] else: vmin = min(lcolor) if ('maxv' in keywords): vmax = keywords['maxv'] else: vmax = max(lcolor) cx = cm.jet cx.set_over('r') cx.set_under('w') x, y = m(rlon, rlat) if (len(rlon) < 100): scatter(x, y, marker=sgn, c=lcolor, s=30.0, color='w', vmin=vmin, vmax=vmax, cmap=cx) # , markersize=11) else: scatter(x, y, marker=sgn, c=lcolor, s=26, edgecolor='w', vmin=vmin, vmax=vmax, cmap=cx) # , markersize=6) cbar_vert = 1 if ('cbar_vert' in keywords): cbar_vert = keywords['cbar_vert'] if (cbar_vert == 1): orientation = 'vertical' else: orientation = 'horizontal' show_colorbar = 0 if ('cb' in keywords): show_colorbar = keywords['cb'] if (show_colorbar == 1): colorbar(orientation=orientation) # colorbar(cmap=cx) m.drawcoastlines(color='k', linewidth=1.0) m.drawmapboundary() # m.drawcountries(color='k', linewidth=0.5) if ('title' in keywords): stitle = keywords['title'] title(stitle) return m
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') # draw coastlines, country boundaries, fill continents. map.drawcoastlines(linewidth=0.25) map.drawcountries(linewidth=0.25) 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,32.73,38.55,48.25,17.29] lons=[-105.16,-117.16,-77.00,-114.21,-88.10] cities=['Boulder, CO','San Diego, 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,fontsize=9) # make up some data on a regular lat/lon grid. nlats = 73; nlons = 145; delta = 2.*p.pi/(nlons-1) lats = (0.5*p.pi-delta*p.indices((nlats,nlons))[0,:,:]) lons = (delta*p.indices((nlats,nlons))[1,:,:])
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) #cs = m1.imshow(mapM, cmap=palette, norm = matplotlib.colors.normalize(vmin=minv, vmax=maxv, clip=False) ) m1.drawmapboundary(color='k', linewidth=1.0, ax=None) #cs = m1.contourf(x,y,mapM, cmap=palette, norm = colors.normalize(vmin=-2, vmax=2, clip=False) ) #im = imshow(mapM, interpolation='bilinear', cmap=palette, norm = colors.normalize(vmin = -1.0, vmax = 1.0, clip = False), origin='lower', extent=[-3,3,-3,3]) #cs = imshow(mapM, cmap=palette, norm = colors.normalize(vmin=minv, vmax=maxv, clip=False) ) # EXPERIMENTAL BEGIN #s='nofile' #mapfile = s+'.lonlatT' #lonfile = s+'.lon' #latfile = s+'.lat' #map=array(load(mapfile)) #lons=array(load(lonfile)) #lats=array(load(latfile)) #map,lons = shiftgrid(180,map,lons,start=False) #subplots_adjust(left=0,right=.99,top=0.99,bottom=0.1,wspace=0,hspace=0) #m2 = Basemap(projection='moll',lon_0=0.5*(lons[0]+lons[-1]))
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') # draw coastlines, country boundaries, fill continents. map.drawcoastlines(linewidth=0.25) map.drawcountries(linewidth=0.25) 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, 32.73, 38.55, 48.25, 17.29] lons = [-105.16, -117.16, -77.00, -114.21, -88.10] cities = [ 'Boulder, CO', 'San Diego, 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, fontsize=9) # make up some data on a regular lat/lon grid. nlats = 73
def display(self, dirc, **keywords): """ display the data keywords: dict which can include the following keywords minv=0.0, maxv=0.0, dv=0.0, show_map=0, map_proj='cyl', show_lat=0, show_lon=0, lat_0=0.0, lon_0=0.0, minlat=-90.0, maxlat=90.0, minlon=0.0, maxlon=360.0, use_log=0, level=level """ rlat = self.grid.get_lat() rlon = self.grid.get_lon() levels = self.grid.get_z() minv = 0.0 if ('minv' in keywords): minv = keywords['minv'] maxv = 0.0 if ('maxv' in keywords): maxv = keywords['maxv'] dv = 0.0 if ('dv' in keywords): dv = keywords['dv'] show_map = 0 if ('dv' in keywords): dv = keywords['dv'] factor = 1.0 if ('factor' in keywords): factor = keywords['factor'] if (maxv > minv): rlvl = arange(minv, maxv + dv, dv) rlvl[0] = -999.0 rlvl[size(rlvl) - 1] = 999. show_map = 0 if ('show_map' in keywords): show_map = keywords['show_map'] stitle = "" if ('name' in self.attr): add_str = self.attr['name'] else: add_str = self.category add_str = add_str.strip() stitle = stitle + ' ' + add_str if ('traunit' in self.attr): add_str = self.attr['traunit'] else: add_str = self.unit add_str = self.unit add_str = add_str.strip() cbar_vert = 1 if ('cbar_vert' in keywords): cbar_vert = keyowrds['cbar_vert'] if (cbar_vert == 1): orientation = 'vertical' else: orientation = 'horizontal' stitle = stitle + ' (' + add_str + ')' if ('tau0' in self.attr): tau0 = self.attr['tau0'] tau0 = 3600. * tau0 # convert to seconds utc = tm.tai85_to_utc(tau0) stitle = stitle + ' ' + utc if (show_map == 1): level = 0 if ('level' in keywords): level = keywords['level'] show_lat = 1 if ('show_lat' in keywords): show_lat = keywords['show_lat'] show_lon = 1 if ('show_lon' in keywords): show_lon = keywords['show_lon'] vals = self.data[:, :, level] vals = array(vals) vals = factor * vals map_proj = 'cyl' if ('map_proj' in keywords): map_proj = keywords['map_proj'] lat_0 = 0.0 if ('lat_0' in keywords): lat_0 = keywords['lat_0'] minlat = -90.0 if ('minlat' in keywords): minlat = keywords['minlat'] maxlat = 90.0 if ('maxlat' in keywords): maxlat = keywords['maxlat'] if (self.grid.centre180 == 0): minlon = 0.0 maxlon = 360.0 lon_0 = 180 else: minlon = -180 maxlon = 180.0 lon_0 = 0 if ('minlon' in keywords): minlon = keywords['minlon'] if ('maxlon' in keywords): maxlon = keywords['maxlon'] if ('lon_0' in keywords): lon_0 = keywords['lon_0'] boundinglat = 45 if ('boundinglat' in keywords): boundinglat = keywords['boundinglat'] if (map_proj == 'npstere' or map_proj == 'spstere'): m = Basemap(projection=map_proj, lon_0=lon_0, boundinglat=boundinglat) elif (map_proj == 'ortho'): m = Basemap(projection=map_proj, lon_0=lon_0, lat_0=lat_0) else: m = Basemap(llcrnrlon=minlon, llcrnrlat=minlat, urcrnrlon=maxlon, urcrnrlat=maxlat, projection=map_proj, lon_0=lon_0, lat_0=lat_0) if (rlon[-1] < rlon[0] + 360.0): rlon = resize(rlon, self.grid.ix + 1) rlon[-1] = rlon[0] + 360.0 vals = squeeze(vals) vals = resize(vals, [self.grid.ix + 1, self.grid.jx]) x, y = m(*meshgrid(rlon, rlat)) if (maxv > minv): cs0 = m.contourf(x, y, transpose(vals), rlvl) else: cs0 = m.contourf(x, y, transpose(vals)) m.drawcoastlines() m.drawcountries() m.drawmapboundary() if (show_lat == 1): print(minlat, maxlat) print(minlon, maxlon) m.drawparallels(arange(minlat, maxlat + 30.0, 30.), labels=[1, 0, 0, 0]) if (show_lon == 1): m.drawmeridians(arange(minlon, maxlon + 60, 60.), labels=[0, 0, 0, 1]) title(stitle) colorbar(orientation=orientation) elif (dirc == 0): level = 0 if ('level' in keywords): lvl = keywords['level'] vals = self.data[:, :, level] vals = factor * vals print(shape(vals), shape(rlon), shape(rlat)) if (maxv > minv): contourf(rlon, rlat, transpose(vals), rlvl) else: contourf(rlon, rlat, transpose(vals)) # restart_new title(stitle) xlabel('Lon') ylabel('Lat') colorbar() elif (dirc == 1): vals = average(self.data, axis=0) use_log = 0 if ('use_log' in keywords): use_log = keywords['use_log'] ax = subplot(2, 1, 1) if (use_log == 1): ax.set_yscale('log') levels = self.get_level() if ('level' in keywords): levels = keywords['levels'] if (maxv > minv): contourf(rlon, rlat, transpose(vals), rlvl) else: contourf(rlat, levels, vals) xlabel('Lat') ylabel('Level') title(stitle) colorbar() show() return 0
verts=my_contour.collections[0].get_paths()[0].vertices lon_150=[] lat_150=[] for xy in verts: lon_150.append(xy[0]) lat_150.append(xy[1]) close(f) dd_box=[array(lon_150).min(), array(lon_150).max(), array(lat_150).min(), array(lat_150).max()] fat=0.05 box=[dd_box[0]-fat, dd_box[1]+fat, dd_box[2]-fat, dd_box[3]+fat] f=figure() mapobj= Basemap(projection='merc',lat_0=(box[2]+box[3])/2.0, lon_0=(box[0]+box[1])/2.0,llcrnrlat=box[2], llcrnrlon=box[0], urcrnrlat=box[3] , urcrnrlon=box[1], resolution='l',area_thresh=1., lat_ts=(box[2]+box[3])/2.0) longr, latgr=meshgrid(lons,lats) xx, yy = mapobj(longr, latgr) mapobj.drawmapboundary() mapobj.readshapefile('/flurry/home/scollis/shapes/cstntcd_r','coast',drawbounds=True,linewidth=0.5,color='k',antialiased=1,ax=None) mapobj.contour(xx,yy,angs, levels=[150,30], colors=['r']) mapobj.drawmeridians(array([130.2, 130.4, 130.6, 130.8,131.0,131.2, 131.4]), labels=[1,0,0,1]) mapobj.drawparallels(array([--12.8, -12.6, -12.4, -12.2, -12.0, -11.8, -11.6, -11.4]), labels=[1,0,0,1]) dd_box_xx, dd_box_yy=mapobj(array([dd_box[0], dd_box[1]]),array([dd_box[2], dd_box[3]])) xy=dd_box_xx[0], dd_box_yy[0] width, height= dd_box_xx[1]-dd_box_xx[0], dd_box_yy[1]-dd_box_yy[0] my_patch=matplotlib.patches.Rectangle(xy, width, height, edgecolor='blue', facecolor='white') ax=gca() ax.add_patch(my_patch) radar_xx, radar_yy=mapobj(array([ber_loc[1], gp_loc[1]]), array([ber_loc[0], gp_loc[0]])) mapobj.plot(radar_xx, radar_yy, 'bo') ax.text(radar_xx[0]+1000.0, radar_yy[0]-3000.0, 'Berrimah') ax.text(radar_xx[1]+1000.0, radar_yy[1]-3000.0, 'Gunn Point') savefig('/flurry/home/scollis/results/area_vis.png')