SF.net SVN: matplotlib: [4969] trunk/toolkits/basemap/Changelog
Revision: 4969 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4969&view=rev Author: jswhit Date: 2008-02-15 05:17:50 -0800 (Fri, 15 Feb 2008) Log Message: --- added warpimage method Modified Paths: -- trunk/toolkits/basemap/Changelog Modified: trunk/toolkits/basemap/Changelog === --- trunk/toolkits/basemap/Changelog2008-02-15 13:16:54 UTC (rev 4968) +++ trunk/toolkits/basemap/Changelog2008-02-15 13:17:50 UTC (rev 4969) @@ -10,6 +10,8 @@ the python module bundled with the GEOS library. * some fixes/enhancements for omerc projection (added 'no_rot' flag). + * added warpimage method for displaying an image background. + Default is NASA's blue marble image, which is included. version 0.9.9.1 (svn revision 4808) * require python 2.4 (really only needed for building). Once namespace packages are re-enabled in matplotlib, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib: [4970] trunk/toolkits/basemap
Revision: 4970
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4970&view=rev
Author: jswhit
Date: 2008-02-15 05:43:19 -0800 (Fri, 15 Feb 2008)
Log Message:
---
added warpimage method
Modified Paths:
--
trunk/toolkits/basemap/README
trunk/toolkits/basemap/examples/run_all.py
Modified: trunk/toolkits/basemap/README
===
--- trunk/toolkits/basemap/README 2008-02-15 13:17:50 UTC (rev 4969)
+++ trunk/toolkits/basemap/README 2008-02-15 13:43:19 UTC (rev 4970)
@@ -16,6 +16,9 @@
setuptools (only if your are using python 2.3)
+PIL (http://pythonware.com/products/pil) is optional (only
+needed for Basemap warpimage method).
+
**Copyright**
source code from proj.4 (http://proj.maptools.org) is included in the
Modified: trunk/toolkits/basemap/examples/run_all.py
===
--- trunk/toolkits/basemap/examples/run_all.py 2008-02-15 13:17:50 UTC (rev
4969)
+++ trunk/toolkits/basemap/examples/run_all.py 2008-02-15 13:43:19 UTC (rev
4970)
@@ -5,7 +5,6 @@
test_files.remove('plotsst.py')
test_files.remove('testgdal.py')
test_files.remove('pnganim.py')
-test_files.remove('warpimage.py')
test_files.remove('geos_demo_2.py')
print test_files
py_path = os.environ.get('PYTHONPATH')
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib: [4968] trunk/toolkits/basemap
Revision: 4968
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4968&view=rev
Author: jswhit
Date: 2008-02-15 05:16:54 -0800 (Fri, 15 Feb 2008)
Log Message:
---
add warpimage method.
Modified Paths:
--
trunk/toolkits/basemap/MANIFEST.in
trunk/toolkits/basemap/examples/README
trunk/toolkits/basemap/examples/warpimage.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
trunk/toolkits/basemap/setup.py
Added Paths:
---
trunk/toolkits/basemap/examples/earth_lights_lrg.jpg
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/data/bmng.jpg
Removed Paths:
-
trunk/toolkits/basemap/examples/bmng.jpg
Modified: trunk/toolkits/basemap/MANIFEST.in
===
--- trunk/toolkits/basemap/MANIFEST.in 2008-02-14 23:18:09 UTC (rev 4967)
+++ trunk/toolkits/basemap/MANIFEST.in 2008-02-15 13:16:54 UTC (rev 4968)
@@ -49,7 +49,7 @@
include examples/run_all.py
include examples/polarmaps.py
include examples/warpimage.py
-include examples/bmng.jpg
+include examples/earth_lights_lrg.jpg
include examples/pnganim.py
include examples/garp.py
include examples/setwh.py
Modified: trunk/toolkits/basemap/examples/README
===
--- trunk/toolkits/basemap/examples/README 2008-02-14 23:18:09 UTC (rev
4967)
+++ trunk/toolkits/basemap/examples/README 2008-02-15 13:16:54 UTC (rev
4968)
@@ -81,8 +81,8 @@
projections (prefixed by 'np' and 'sp').
warpimage.py shows how to interpolate (warp) an image from one
-map projection to another. Requires PIL, and an image from
-http://www.space-graphics.com/earth_topo-bathy.htm,
+map projection to another using the 'warpimage' Basemap method.
+Requires PIL.
garp.py makes a 'World According to Garp' map - an azimuthal equidistant
projection centered on a specified location. Straight lines from that
Deleted: trunk/toolkits/basemap/examples/bmng.jpg
===
(Binary files differ)
Added: trunk/toolkits/basemap/examples/earth_lights_lrg.jpg
===
(Binary files differ)
Property changes on: trunk/toolkits/basemap/examples/earth_lights_lrg.jpg
___
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/toolkits/basemap/examples/warpimage.py
===
--- trunk/toolkits/basemap/examples/warpimage.py2008-02-14 23:18:09 UTC
(rev 4967)
+++ trunk/toolkits/basemap/examples/warpimage.py2008-02-15 13:16:54 UTC
(rev 4968)
@@ -1,53 +1,35 @@
import pylab as P
import numpy
-from mpl_toolkits.basemap import Basemap as Basemap1
-from numpy import ma
+from mpl_toolkits.basemap import Basemap
-class Basemap(Basemap1):
-# subclass Basemap and add bluemarble method.
-def bluemarble(self,masked=False):
-"""display 'blue marble next generation' image from
http://visibleearth.nasa.gov/""";
-try:
-from PIL import Image
-except ImportError:
-raise ImportError('bluemarble method requires PIL
(http://www.pythonware.com/products/pil/)')
-from matplotlib.image import pil_to_array
-
-# read in jpeg image to rgba array of normalized floats.
-pilImage = Image.open('bmng.jpg')
-rgba = pil_to_array(pilImage)
-rgba = rgba.astype(numpy.float32)/255. # convert to normalized floats.
-
-# define lat/lon grid that image spans (projection='cyl').
-nlons = rgba.shape[1]; nlats = rgba.shape[0]
-delta = 360./float(nlons)
-lons = numpy.arange(-180.+0.5*delta,180.,delta)
-lats = numpy.arange(-90.+0.5*delta,90.,delta)
+# illustrate use of warpimage method to display an image background
+# on the map projection region. Default background is the 'blue
+# marble' image from NASA (http://visibleearth.nasa.gov).
-if self.projection != 'cyl':
-# transform to nx x ny regularly spaced native projection grid
-# nx and ny chosen to have roughly the same horizontal res as
original image.
-dx = 2.*numpy.pi*m.rmajor/float(nlons)
-nx = int((self.xmax-self.xmin)/dx)+1; ny =
int((self.ymax-self.ymin)/dx)+1
-rgba_warped = ma.zeros((ny,nx,4),numpy.float64)
-# interpolate rgba values from proj='cyl' (geographic coords) to
'lcc'
-# if masked=True, values outside of projection limb will be masked.
-for k in range(4):
-rgba_warped[:,:,k] =
self.transform_scalar(rgba[:,:,k],lons,lats,nx,ny,masked=masked)
-# make points outside projection limb transparent.
-rgba_warped = rgba_warped.filled(0.)
-# plot warped rgba image.
-im = self.imshow(rgb
SF.net SVN: matplotlib: [4971] trunk/toolkits/basemap/lib/mpl_toolkits/ basemap/basemap.py
Revision: 4971
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4971&view=rev
Author: jswhit
Date: 2008-02-15 05:45:41 -0800 (Fri, 15 Feb 2008)
Log Message:
---
fix typo in warpimage method
Modified Paths:
--
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
===
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py 2008-02-15
13:43:19 UTC (rev 4970)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py 2008-02-15
13:45:41 UTC (rev 4971)
@@ -2686,7 +2686,7 @@
try:
from PIL import Image
except ImportError:
-raise ImportError('bluemarble method requires PIL
(http://www.pythonware.com/products/pil/)')
+raise ImportError('warpimage method requires PIL
(http://www.pythonware.com/products/pil)')
from matplotlib.image import pil_to_array
if not kwargs.has_key('ax') and self.ax is None:
try:
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib: [4974] trunk/toolkits/basemap/README
Revision: 4974 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4974&view=rev Author: jswhit Date: 2008-02-15 08:01:52 -0800 (Fri, 15 Feb 2008) Log Message: --- update Modified Paths: -- trunk/toolkits/basemap/README Modified: trunk/toolkits/basemap/README === --- trunk/toolkits/basemap/README 2008-02-15 16:01:05 UTC (rev 4973) +++ trunk/toolkits/basemap/README 2008-02-15 16:01:52 UTC (rev 4974) @@ -17,7 +17,7 @@ setuptools (only if your are using python 2.3) PIL (http://pythonware.com/products/pil) is optional (only -needed for Basemap warpimage method). +needed for Basemap warpimage and bluemarble methods). **Copyright** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib: [4973] trunk/toolkits/basemap/examples/wiki_example .py
Revision: 4973
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4973&view=rev
Author: jswhit
Date: 2008-02-15 08:01:05 -0800 (Fri, 15 Feb 2008)
Log Message:
---
added blue marble background
Modified Paths:
--
trunk/toolkits/basemap/examples/wiki_example.py
Modified: trunk/toolkits/basemap/examples/wiki_example.py
===
--- trunk/toolkits/basemap/examples/wiki_example.py 2008-02-15 15:47:46 UTC
(rev 4972)
+++ trunk/toolkits/basemap/examples/wiki_example.py 2008-02-15 16:01:05 UTC
(rev 4973)
@@ -35,6 +35,39 @@
x, y = map(lons*180./p.pi, lats*180./p.pi)
# contour data over the map.
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
+
+# as above, but use blue marble image as map background.
+fig = p.figure()
+map = Basemap(projection='ortho',lat_0=50,lon_0=-100,resolution='l')
+map.drawmapboundary()
+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,'yo')
+# plot the names of those five cities.
+for name,xpt,ypt in zip(cities,x,y):
+p.text(xpt+5,ypt+5,name,fontsize=9,color='w')
+# 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,:,:])
+wave = 0.75*(p.sin(2.*lats)**8*p.cos(4.*lons))
+mean = 0.5*p.cos(2.*lats)*((p.sin(2.*lats))**2 + 2.)
+# compute native map projection coordinates of lat/lon grid.
+x, y = map(lons*180./p.pi, lats*180./p.pi)
+# contour data over the map.
+cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
+# draw blue marble image in background.
+map.bluemarble()
p.show()
+
#p.savefig('wiki_example.ps')
+
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins
SF.net SVN: matplotlib: [4972] trunk/toolkits/basemap
Revision: 4972
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4972&view=rev
Author: jswhit
Date: 2008-02-15 07:47:46 -0800 (Fri, 15 Feb 2008)
Log Message:
---
added "bluemarble" method, make sure data is cached correctly in warpimage.
Modified Paths:
--
trunk/toolkits/basemap/examples/README
trunk/toolkits/basemap/examples/warpimage.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
Modified: trunk/toolkits/basemap/examples/README
===
--- trunk/toolkits/basemap/examples/README 2008-02-15 13:45:41 UTC (rev
4971)
+++ trunk/toolkits/basemap/examples/README 2008-02-15 15:47:46 UTC (rev
4972)
@@ -80,9 +80,8 @@
stereographic, lambert azimuthal equal area, azimuthal equidistant
projections (prefixed by 'np' and 'sp').
-warpimage.py shows how to interpolate (warp) an image from one
-map projection to another using the 'warpimage' Basemap method.
-Requires PIL.
+warpimage.py shows how to use an image as a map background with the
+'warpimage' and 'bluemarble' Basemap methods. Requires PIL.
garp.py makes a 'World According to Garp' map - an azimuthal equidistant
projection centered on a specified location. Straight lines from that
Modified: trunk/toolkits/basemap/examples/warpimage.py
===
--- trunk/toolkits/basemap/examples/warpimage.py2008-02-15 13:45:41 UTC
(rev 4971)
+++ trunk/toolkits/basemap/examples/warpimage.py2008-02-15 15:47:46 UTC
(rev 4972)
@@ -11,7 +11,7 @@
# define orthographic projection centered on North America.
m = Basemap(projection='ortho',lat_0=40,lon_0=-100,resolution='l')
# display a non-default image.
-m.warpimage(file='earth_lights_lrg.jpg')
+m.warpimage(image='earth_lights_lrg.jpg')
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines every 30 degrees.
@@ -20,16 +20,16 @@
P.title("Lights at Night image warped from 'cyl' to 'ortho'
projection",fontsize=12)
print 'warp to orthographic map ...'
-# redisplay should be fast.
+# redisplay (same image specified) should be fast since data is cached.
fig = P.figure()
-m.warpimage()
+m.warpimage(image='earth_lights_lrg.jpg')
# create new figure
fig=P.figure()
# define cylindrical equidistant projection.
m =
Basemap(projection='cyl',llcrnrlon=-180,llcrnrlat=-90,urcrnrlon=180,urcrnrlat=90,resolution='l')
# plot (unwarped) rgba image.
-im = m.warpimage()
+im = m.bluemarble()
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines.
@@ -43,7 +43,7 @@
# define orthographic projection centered on Europe.
m = Basemap(projection='ortho',lat_0=40,lon_0=40,resolution='l')
# plot warped rgba image.
-im = m.warpimage(masked=True)
+im = m.bluemarble()
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw lat/lon grid lines every 30 degrees.
@@ -58,7 +58,7 @@
m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
rsphere=(6378137.00,6356752.3142),lat_1=50.,lon_0=-107.,\
resolution='i',area_thresh=1000.,projection='lcc')
-im = m.warpimage()
+im = m.bluemarble()
# draw coastlines.
m.drawcoastlines(linewidth=0.5,color='0.5')
# draw parallels and meridians.
@@ -77,7 +77,7 @@
resolution=None,projection='omerc',\
lon_0=-100,lat_0=15,lon_2=-120,lat_2=65,lon_1=-50,lat_1=-55)
# plot warped rgba image.
-im = m.warpimage()
+im = m.bluemarble()
# draw lat/lon grid lines every 20 degrees.
m.drawmeridians(numpy.arange(0,360,20),color='0.5')
m.drawparallels(numpy.arange(-80,81,20),color='0.5')
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
===
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py 2008-02-15
13:45:41 UTC (rev 4971)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py 2008-02-15
15:47:46 UTC (rev 4972)
@@ -2674,8 +2674,18 @@
im = self.imshow(rgba,interpolation='nearest',ax=ax,**kwargs)
return im
-def warpimage(self,file=None,**kwargs):
+def bluemarble(self,ax=None):
"""
+display blue marble image (from http://visibleearth.nasa.gov)
+as map background.
+"""
+if ax is not None:
+self.warpimage(image='bluemarble',ax=ax)
+else:
+self.warpimage(image='bluemarble')
+
+def warpimage(self,image="bluemarble",**kwargs):
+"""
display an image (given by file keyword) as a background.
Default (if file not specified) is to display
'blue marble next generation' image from http://visibleearth.nasa.gov/.
@@ -2700,25 +2710,31 @@
ax = kwargs.pop('ax')
# default image file is blue marble next generation
# from NASA (http://visibleearth.nasa.gov).
-if file is None:
+if
