def drawmap(self): lllon,urlon,lllat,urlat=self.source_dim m = Basemap(lllon,lllat,urlon,urlat,projection='merc',resolution='l') m.drawmapboundary(fill_color='aqua') # fill continents, set lake color same as ocean color. m.drawcoastlines() m.fillcontinents(color='coral',lake_color='aqua') if urlon - lllon < 2.5: dlon = 0.5 elif urlon - lllon < 5.: dlon =1.0 else: dlon = 2. m.drawparallels(np.arange(-90.,90.,1.0),labels=[1,0,0,0]) m.drawmeridians(np.arange(-180.,180.,dlon),labels=[0,0,0,1]) return m
def vizInterp(nLons, nLats, ufunct, vfunct, files): '''Creates a visualization of the interpolation function nLons: list of mesh node logitudes nLats: list of mesh node latitudes uFunct: interpolation function of interpolated current u component magnitudes at each mesh node vFunct: interpolation function of interpolated current v component magnitudes at each mesh node files: list of file input names and directories for data retreival. ''' iModule = np.sqrt(ufunct**2 + vfunct**2) * 1.94384 m = Basemap(llcrnrlon=-100., llcrnrlat=0., urcrnrlon=30., urcrnrlat=70, projection='merc', resolution='l') x, y = m(np.array(nLons), np.array(nLats)) print x[:10] print y[:10] print iModule.squeeze()[:10] #print len(iModule.squeeze()) #print len(x) sys.exit() m.drawcoastlines() #m.fillcontinents(color='coral',lake_color='white') m.drawparallels(np.arange(0., 81., 20.), labels=[True, False, False, False]) m.drawmeridians(np.arange(-180., 181., 20.), labels=[False, False, False, True]) #m.drawmapboundary(fill_color='aqua') m.pcolormesh(x, y, iModule.squeeze(), cmap='jet', vmin=0, vmax=2) #m.quiver(x[::n, ::n], y[::n, ::n], ufunct[::n, ::n], vfunct[::n, ::n], scale=10, pivot='mid') m.colorbar(ticks=np.arange(0, 2.1, .2)) plt.savefig(files[8], bbox_inches='tight') plt.show()
resolution='f') # Borders for Papua New Guinea (approximate for now) # East: 8.23.18.4.S 165.11.08.7.E # West: 5.50.46.7.S 139.47.10.4.E # North: 0.05'58.7"S 149.32'31.5"E # South: 12.26'14.3"S 151.49'38.0"E # Precip bins to be used for precip clevs = [0, 1, 2.5, 5, 7.5, 10, 15, 20, 30, 40, 50, 70, 100, 150] # More map configuration # draw coastlines, country boundaries m.drawcoastlines(linewidth=0.25) m.drawcountries(linewidth=0.25) # draw parallels. parallels = np.arange(-40., 40, 10.) m.drawparallels(parallels, labels=[1, 0, 0, 0], fontsize=10) # draw meridians meridians = np.arange(80., 180., 10.) m.drawmeridians(meridians, labels=[0, 0, 0, 1], fontsize=10) # Make grid for TRMM data ny = trmm_precip.shape[0] nx = trmm_precip.shape[1] lons, lats = m.makegrid(nx, ny) # get lat/lons of ny by nx evenly spaced grid. x, y = m(lons, lats) # compute map proj coordinates. # Make grid for SACA data
"#fd0000", # 3.00 - 4.00 inches "#d40000", # 4.00 - 5.00 inches "#bc0000", # 5.00 - 6.00 inches "#f800fd", # 6.00 - 8.00 inches "#9854c6", # 8.00 - 10.00 inches "#fdfdfd" # 10.00+ ] precip_colormap = matplotlib.colors.ListedColormap(nws_precip_colors) # Precip bins to be used for precip clevs = [0,1,2.5,5,7.5,10,15,20,30,40,50,70,100,150] # More map configuration # draw coastlines, country boundaries m.drawcoastlines(linewidth=0.25) m.drawcountries(linewidth=0.25) # draw parallels. parallels = np.arange(-40.,40,10.) m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10) # draw meridians meridians = np.arange(80.,180.,10.) m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10) # Make grid for TRMM data # ny = trmm_precip.shape[0] # nx = trmm_precip.shape[1] # lons, lats = m.makegrid(nx, ny) # get lat/lons of ny by nx evenly spaced grid. # x, y = m(lons, lats) # compute map proj coordinates.
# Good colormap from hclwizard.org colors = ("#F5A5FF", "#C4B7FF", "#78CAFF", "#00D9FF", "#00E3FF", "#00E9E8", "#00EAC4", "#00E89A", "#26E46A", "#87DC25", "#B9D300", "#DEC900", "#FCBC00", "#FFAF58", "#FFA28D", "#FF97BA") print 'plt_diff_fc_abs_error' fig, axarr = plt.subplots(1, 2, figsize=(7.87, 3)) for itim, tim in enumerate(timelist): print itim, tim dateobj = datetime.datetime.strptime(tim, '%Y%m%d') ax = axarr[itim] plt.sca(ax) m = Basemap(projection='cyl', llcrnrlon=-40, \ urcrnrlon=30.,llcrnrlat=25,urcrnrlat=80, \ resolution='i', area_thresh=10000.) m.drawcoastlines(False) m.drawcountries() m.drawcoastlines(linewidth=0.5) x, y = m(lon, lat) mylevels = np.arange(520, 590, 5) # cs0 = m.contourf(x,y,((datadict_od_geopot_500[itim][timelist[itim]]/9.80665)/10.)-((datadict_od_geopot_1000[itim][timelist[itim]]/9.80665)/10.), # shading='flat',latlon=True, levels=mylevels, # cmap=plt.cm.gist_rainbow_r, extend = 'both', # alpha=0.8) # cs1 = m.contour(x,y,(datadict_od_geopot_500[itim][timelist[itim]]/9.80665)/10., # latlon = True, levels = np.arange(520,581,5), # colors='k', linewidths=2, # zorder=3) cs1 = m.contourf( x, y, (datadict_od_geopot_500[itim][timelist[itim]] / 9.80665) / 10.,