224 lines (211 with data), 19.0 kB
@header@
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="matplotlib.html"><font color="#ffffff">matplotlib</font></a>.<a href="matplotlib.toolkits.html"><font color="#ffffff">toolkits</font></a>.<a href="matplotlib.toolkits.basemap.html"><font color="#ffffff">basemap</font></a>.basemap</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/lib/python2.3/site-packages/matplotlib/toolkits/basemap/basemap.py">/usr/local/lib/python2.3/site-packages/matplotlib/toolkits/basemap/basemap.py</a></font></td></tr></table>
<p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="MLab.html">MLab</a><br>
<a href="numarray.html">numarray</a><br>
</td><td width="25%" valign=top><a href="numarray.nd_image.html">numarray.nd_image</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="matplotlib.toolkits.basemap.basemap.html#Basemap">Basemap</a>
</font></dt></dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Basemap">class <strong>Basemap</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt> Set up a basemap with a given map projection (cylindrical equidistant,<br>
mercator, lambert conformal conic, lambert azimuthal equal area,<br>
albers equal area conic and stereographic are currently available).<br>
Doesn't actually draw anything, but sets up the map projection class and<br>
creates the coastline and political boundary polygons in native map <br>
projection coordinates. Requires matplotlib and numarray.<br>
Uses a pyrex interface to C-code from proj.4 (<a href="http://proj.maptools.org">http://proj.maptools.org</a>).<br>
<br>
Useful instance variables:<br>
<br>
projection - map projection ('cyl','merc','lcc','aea','laea' or 'stere')<br>
aspect - map aspect ratio (size of y dimension / size of x dimension).<br>
llcrnrlon - longitude of lower left hand corner of the desired map domain.<br>
llcrnrlon - latitude of lower left hand corner of the desired map domain. <br>
urcrnrlon - longitude of upper right hand corner of the desired map domain.<br>
urcrnrlon - latitude of upper right hand corner of the desired map domain.<br>
llcrnrx,llcrnry,urcrnrx,urcrnry - corners of map domain in projection coordinates.<br>
<br>
Example Usage:<br>
(this example plus others can be run by running test.py in the examples dir)<br>
<br>
>>> from matplotlib.toolkits.basemap import <a href="#Basemap">Basemap</a><br>
>>> import cPickle<br>
>>> from pylab import *<br>
>>> # read in topo data from pickle (on a regular lat/lon grid)<br>
>>> topodict = cPickle.load(open('etopo20.pickle','rb'))<br>
>>> etopo = topodict['data']; lons = topodict['lons']; lats = topodict['lats']<br>
>>> m = <a href="#Basemap">Basemap</a>(lons[0],lats[0],lons[-1],lats[-1])<br>
>>> xsize = rcParams['figure.figsize'][0]<br>
>>> fig=figure(figsize=(xsize,m.aspect*xsize))<br>
>>> fig.add_axes([0.1,0.1,0.8,0.8])<br>
>>> im = imshow(etopo,extent=(m.llcrnrx,m.urcrnrx,m.llcrnry,m.urcrnry),origin='lower')<br>
>>> ax = gca() # get current axis instance<br>
>>> # draw coastlines and fill continents.<br>
>>> m.<a href="#Basemap-drawcoastlines">drawcoastlines</a>(ax)<br>
>>> m.<a href="#Basemap-fillcontinents">fillcontinents</a>(ax)<br>
>>> # draw parallels<br>
>>> circles = arange(-90.,120.,30.)<br>
>>> m.<a href="#Basemap-drawparallels">drawparallels</a>(ax,circles)<br>
>>> # draw meridians<br>
>>> meridians = arange(0.,390.,60.)<br>
>>> m.<a href="#Basemap-drawmeridians">drawmeridians</a>(ax,meridians)<br>
>>> ax.set_xticks([]) # no ticks<br>
>>> ax.set_yticks([])<br>
>>> title('Cylindrical Equidistant')<br>
>>> show()<br>
<br>
Version: 0.1 (20050203)<br>
Contact: Jeff Whitaker <jeffrey.s.whitaker@noaa.gov><br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Basemap-__call__"><strong>__call__</strong></a>(self, x, y, inverse<font color="#909090">=False</font>)</dt><dd><tt>Calling a <a href="#Basemap">Basemap</a> class instance with the arguments lon, lat will<br>
convert lon/lat (in degrees) to x/y native map projection <br>
coordinates (in meters). If optional keyword 'inverse' is<br>
True (default is False), the inverse transformation from x/y<br>
to lon/lat is performed.<br>
<br>
For cylindrical equidistant projection ('cyl'), this<br>
does nothing (i.e. x,y == lon,lat).<br>
<br>
For mercator projection ('merc'), x == lon, but y has units<br>
of meters.<br>
<br>
lon,lat can be either scalar floats or N arrays.</tt></dd></dl>
<dl><dt><a name="Basemap-__init__"><strong>__init__</strong></a>(self, llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, resolution<font color="#909090">='c'</font>, area_thresh<font color="#909090">=10000.0</font>, projection<font color="#909090">='cyl'</font>, rsphere<font color="#909090">=6371009.0</font>, lat_ts<font color="#909090">=None</font>, lat_1<font color="#909090">=None</font>, lat_2<font color="#909090">=None</font>, lat_0<font color="#909090">=None</font>, lon_0<font color="#909090">=None</font>)</dt><dd><tt>create a <a href="#Basemap">Basemap</a> instance.<br>
<br>
mandatory input arguments:<br>
<br>
llcrnrlon - longitude of lower left hand corner of the desired map domain.<br>
llcrnrlon - latitude of lower left hand corner of the desired map domain. <br>
urcrnrlon - longitude of upper right hand corner of the desired map domain.<br>
urcrnrlon - latitude of upper right hand corner of the desired map domain.<br>
<br>
optional keyword parameters:<br>
<br>
resolution - resolution of coastline database to use. Can be 'c' (crude, <br>
roughly 25 km resolution) or 'l' (low, roughly 5 km resolution). Default 'c'.<br>
Coastline data is from the GSHHS <br>
(<a href="http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html">http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html</a>).<br>
area_thresh - coastline with an area smaller than area_thresh in km^2<br>
will not be plotted. Default 10,000.<br>
projection - map projection. 'cyl' - cylindrical equidistant, 'merc' -<br>
mercator, 'lcc' - lambert conformal conic, 'stere' - stereographic,<br>
'aea' - albers equal area conic, and <br>
'laea' - lambert azimuthal equal area currently available. Default 'cyl'.<br>
rsphere - radius of the sphere used to define map projection (default<br>
6371009 meters, close to the arithmetic mean radius of the earth).<br>
<br>
The following parameters are map projection parameters which all default to <br>
None. Not all parameters are used by all projections, some are ignored.<br>
<br>
lat_ts - latitude of natural origin (used for mercator and stereographic<br>
projections).<br>
lat_1 - first standard parallel for lambert conformal and albers<br>
equal area projections.<br>
lat_2 - second standard parallel for lambert conformal and albers<br>
equal area projections.<br>
lat_0 - central latitude (y-axis origin) - used by stereographic and<br>
lambert azimuthal projections).<br>
lon_0 - central meridian (x-axis origin - used by lambert conformal<br>
and lambert azimuthal and stereographic projections).</tt></dd></dl>
<dl><dt><a name="Basemap-drawcoastlines"><strong>drawcoastlines</strong></a>(self, ax, linewidth<font color="#909090">=1.0</font>, color<font color="#909090">='k'</font>, antialiased<font color="#909090">=1</font>)</dt><dd><tt>Draw coastlines.<br>
<br>
ax - current axis instance.<br>
linewidth - coastline width (default 1.)<br>
color - coastline color (default black)<br>
antialiased - antialiasing switch for coastlines (default True).</tt></dd></dl>
<dl><dt><a name="Basemap-drawcountries"><strong>drawcountries</strong></a>(self, ax, linewidth<font color="#909090">=0.5</font>, color<font color="#909090">='k'</font>, antialiased<font color="#909090">=1</font>)</dt><dd><tt>Draw country boundaries.<br>
<br>
ax - current axis instance.<br>
linewidth - country boundary line width (default 0.5)<br>
color - country boundary line color (default black)<br>
antialiased - antialiasing switch for country boundaries (default True).</tt></dd></dl>
<dl><dt><a name="Basemap-drawmeridians"><strong>drawmeridians</strong></a>(self, ax, meridians, color<font color="#909090">='k'</font>, linewidth<font color="#909090">=1.0</font>, linestyle<font color="#909090">='--'</font>, dashes<font color="#909090">=[1, 1]</font>)</dt><dd><tt>draw meridians (longitude lines).<br>
<br>
ax - current axis instance.<br>
meridians - list containing longitude values to draw (in degrees).<br>
color - color to draw meridians (default black).<br>
linewidth - line width for meridians (default 1.)<br>
linestyle - line style for meridians (default '--', i.e. dashed).<br>
dashes - dash pattern for meridians (default [1,1], i.e. 1 pixel on,<br>
1 pixel off).</tt></dd></dl>
<dl><dt><a name="Basemap-drawparallels"><strong>drawparallels</strong></a>(self, ax, circles, color<font color="#909090">='k'</font>, linewidth<font color="#909090">=1.0</font>, linestyle<font color="#909090">='--'</font>, dashes<font color="#909090">=[1, 1]</font>)</dt><dd><tt>draw parallels (latitude lines).<br>
<br>
ax - current axis instance.<br>
circles - list containing latitude values to draw (in degrees).<br>
color - color to draw parallels (default black).<br>
linewidth - line width for parallels (default 1.)<br>
linestyle - line style for parallels (default '--', i.e. dashed).<br>
dashes - dash pattern for parallels (default [1,1], i.e. 1 pixel on,<br>
1 pixel off).</tt></dd></dl>
<dl><dt><a name="Basemap-drawstates"><strong>drawstates</strong></a>(self, ax, linewidth<font color="#909090">=0.5</font>, color<font color="#909090">='k'</font>, antialiased<font color="#909090">=1</font>)</dt><dd><tt>Draw state boundaries in Americas.<br>
<br>
ax - current axis instance.<br>
linewidth - state boundary line width (default 0.5)<br>
color - state boundary line color (default black)<br>
antialiased - antialiasing switch for state boundaries (default True).</tt></dd></dl>
<dl><dt><a name="Basemap-fillcontinents"><strong>fillcontinents</strong></a>(self, ax, color<font color="#909090">=0.80000000000000004</font>)</dt><dd><tt>Fill continents.<br>
<br>
ax - current axis instance.<br>
color - color to fill continents (default gray).</tt></dd></dl>
<dl><dt><a name="Basemap-makegrid"><strong>makegrid</strong></a>(self, nx, ny)</dt><dd><tt>return arrays of shape (ny,nx) containing lon,lat coordinates of<br>
an equally spaced native projection grid.</tt></dd></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-interp"><strong>interp</strong></a>(datain, lonsin, latsin, lonsout, latsout, checkbounds<font color="#909090">=False</font>, mode<font color="#909090">='nearest'</font>, cval<font color="#909090">=0.0</font>, order<font color="#909090">=3</font>)</dt><dd><tt>dataout = <a href="#-interp">interp</a>(datain,lonsin,latsin,lonsout,latsout,mode='constant',cval=0.0,order=3)<br>
<br>
interpolate data (datain) on a regularly spaced lat/lon grid (with lons=lonsin<br>
lats=latsin) to a grid with lons=lonsout, lats=latsout.<br>
<br>
datain is a rank-2 array with 1st dimension corresponding to longitude,<br>
2nd dimension latitude.<br>
<br>
lonsin, latsin are rank-1 Numeric arrays containing longitudes and latitudes<br>
of datain grid in increasing order (i.e. from Greenwich meridian eastward, and<br>
South Pole northward)<br>
<br>
lonsout, latsout are rank-2 Numeric arrays containing lons and lats out desired<br>
output grid (typically a native map projection grid).<br>
<br>
If checkbounds=True, values of lonsout and latsout are checked to see that<br>
they lie within the range specified by lonsin and latsing. Default is<br>
False, and values outside the borders are handled in the manner described<br>
by the 'mode' parameter (default mode='nearest', which means the nearest<br>
boundary value is used). See section 20.2 of the numarray docs for <br>
information on the 'mode' keyword.<br>
<br>
See numarray.nd_image.map_coordinates documentation for information on<br>
the other optional keyword parameters. The order keyword can be 0 <br>
for nearest neighbor interpolation (nd_image only allows 1-6) - if<br>
order=0 bounds checking is done even if checkbounds=False.</tt></dd></dl>
</td></tr></table>
@footer@