Revision: 4712
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4712&view=rev
Author: jswhit
Date: 2007-12-12 10:24:56 -0800 (Wed, 12 Dec 2007)
Log Message:
-----------
fix up a bit.
Modified Paths:
--------------
trunk/toolkits/basemap/examples/plotsst.py
Modified: trunk/toolkits/basemap/examples/plotsst.py
===================================================================
--- trunk/toolkits/basemap/examples/plotsst.py 2007-12-12 16:57:09 UTC (rev
4711)
+++ trunk/toolkits/basemap/examples/plotsst.py 2007-12-12 18:24:56 UTC (rev
4712)
@@ -4,23 +4,38 @@
# can be a local file, a URL for a remote opendap dataset,
# or (if PyNIO is installed) a GRIB or HDF file.
ncfile =
NetCDFFile('http://nomads.ncdc.noaa.gov:8085/thredds/dodsC/oisst/2007/AVHRR/sst4-navy-eot.20071201.nc')
+# read sst. Will automatically create a masked array using
+# missing_value variable attribute.
sst = ncfile.variables['sst'][:]
+# read lats and lons (representing centers of grid boxes).
lats = ncfile.variables['lat'][:]
lons = ncfile.variables['lon'][:]
+# shift lats, lons so values represent edges of grid boxes
+# (as pcolor expects).
+delon = lons[1]-lons[0]
+delat = lats[1]-lats[0]
+lons = (lons - 0.5*delon).tolist()
+lons.append(lons[-1]+delon)
+lons = numpy.array(lons,numpy.float64)
+lats = (lats - 0.5*delat).tolist()
+lats.append(lats[-1]+delat)
+lats = numpy.array(lats,numpy.float64)
# create Basemap instance for mollweide projection.
# coastlines not used, so resolution set to None to skip
# continent processing (this speeds things up a bit)
m = Basemap(projection='moll',lon_0=lons.mean(),lat_0=0,resolution=None)
# compute map projection coordinates of grid.
x, y = m(*numpy.meshgrid(lons, lats))
-m.drawmapboundary(fill_color='k')
+# draw line around map projection limb.
+# color background of map projection region.
+# missing values over land will show up this color.
+m.drawmapboundary(fill_color='0.3')
# plot with pcolor
-im = m.pcolormesh(x,y,sst,shading='flat',cmap=pylab.cm.gist_ncar)
+im = m.pcolor(x,y,sst,shading='flat',cmap=pylab.cm.gist_ncar)
# draw parallels and meridians, but don't bother labelling them.
m.drawparallels(numpy.arange(-90.,120.,30.))
m.drawmeridians(numpy.arange(0.,420.,60.))
-# draw line around map projection limb.
-# color map region background black (missing values will be this color)
# draw horizontal colorbar.
pylab.colorbar(orientation='horizontal')
+# display the plot.
pylab.show()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins