Hi all, I have a weird thing happening with basemap and I am not sure if it's basemap or me, but more than likely it's me :(
Here is the grib file that I am using: http://downloads.75ive.com/multi_1.20090321.t18z_multi_1.wc_10m.all.grb2 http://downloads.75ive.com/multi_1.20090321.t18z_multi_1.wc_10m.all.grb2 And here is my code: ############################################# import matplotlib import matplotlib.mpl as mpl import matplotlib.pyplot as plt import matplotlib.mlab as mlab import numpy as np import matplotlib.pylab as pylab from mpl_toolkits.basemap import Basemap from grib2 import Grib2Decode grbs = Grib2Decode('multi_1.20090321.t18z_multi_1.wc_10m.all.grb2') lats, lons = grbs[0].grid() mapCoords = [32.35,-121.0,34.75,-116.75] #mapCoords = [lats.min(),lons.min(),lats.max(),lons.max()] colorList = [[0.,0.,205./255.],[0,102./255.,255./255.],[0,183./255.,255./255.],[0,224./255.,255./255.], [0,255./255.,255./255.],[0,255./255.,204./255.],[0,255./255.,153./255.],[0,255./255.,0], [153./255.,255./255.,0],[204./255.,255./255.,0],[255./255.,255./255.,0],[255./255.,204./255.,0], [255./255.,153./255.,0],[255./255.,102./255.,0],[255./255.,0,0],[176./255.,48./255.,96./255.], [208./255.,32./255.,144./255.],[255./255.,0,255./255.]] cmap = matplotlib.colors.ListedColormap(colorList, name = 'theColorMap', N = len(colorList)) m = Basemap(projection='merc',lat_ts = 30,\ llcrnrlat=mapCoords[0],llcrnrlon=mapCoords[1],urcrnrlat=mapCoords[2],urcrnrlon=mapCoords[3],\ resolution='h',area_thresh=0.5, suppress_ticks = True) fig = plt.figure(figsize=(14.58,10.58)) fig.set_dpi(100) nlats, nlons = grbs[0].data().shape x = np.linspace(lons.min(),lons.max(),nlons) y = np.linspace(lats.min(),lats.max(),nlats) X, Y = m(*np.meshgrid(x, y)) z = grbs[0].data().filled(1) m.contourf(X,Y,z,cmap=cmap,levels=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],extend='both') m.fillcontinents(color='green',lake_color='b') m.drawcoastlines(color='k', linewidth=0.75) m.drawcountries(color='k', linewidth=0.25) m.drawstates(color='k', linewidth=0.25) m.drawmapboundary(linewidth=1.0, color='k') plt.show() ############################################# If you look at lines 14 and 15 you can see that i have a variable called mapCoords that feeds the lat/lon coordinates to the basemap object. If i set them up using the commented line (line 15) it will plot the map for all the data in the file and it will display it correctly. If i use line 14 which is the zoomed area that i am interested in it will display the basemap map correctly zoomed in but it will not show the plotted data. Any ideas on what is happening here? Also, if you have any comments on optimizing the code I would really appreciate it! Thanks, Anton -- View this message in context: http://www.nabble.com/basemap-error-or-user-error--tp23017806p23017806.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users