SF.net SVN: matplotlib: [4370] trunk/toolkits/basemap-testing/lib/ matplotlib/toolkits/basemap/basemap.py

2007-11-18 Thread jswhit
Revision: 4370
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4370&view=rev
Author:   jswhit
Date: 2007-11-18 05:32:27 -0800 (Sun, 18 Nov 2007)

Log Message:
---
port over some of Eric's refactoring from trunk

Modified Paths:
--
trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py

Modified: 
trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py
===
--- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-17 22:11:19 UTC (rev 4369)
+++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-18 13:32:27 UTC (rev 4370)
@@ -275,8 +275,8 @@
 projparams['lat_ts'] = lat_ts
 if satellite_height is not None:
 projparams['h'] = satellite_height
-
-if None not in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]:
+using_corners = (None not in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat])
+if using_corners:
 # make sure lat/lon limits are converted to floats.
 self.llcrnrlon = float(llcrnrlon)
 self.llcrnrlat = float(llcrnrlat)
@@ -303,7 +303,7 @@
 raise ValueError, 'must specify lat_1 or lat_0 and lon_0 for 
Lambert Conformal basemap (lat_2 is optional)'
 if lat_2 is None:
projparams['lat_2'] = lat_1
-if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]:
+if not using_corners:
 if width is None or height is None:
 raise ValueError, 'must either specify lat/lon values of 
corners (llcrnrlon,llcrnrlat,ucrnrlon,urcrnrlat) in degrees or width and height 
in meters'
 else:
@@ -323,7 +323,7 @@
 raise ValueError, 'must specify lat_1 or lat_0 and lon_0 for 
Equidistant Conic basemap (lat_2 is optional)'
 if lat_2 is None:
projparams['lat_2'] = lat_1
-if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]:
+if not using_corners:
 if width is None or height is None:
 raise ValueError, 'must either specify lat/lon values of 
corners (llcrnrlon,llcrnrlat,ucrnrlon,urcrnrlat) in degrees or width and height 
in meters'
 else:
@@ -342,7 +342,7 @@
 raise ValueError, 'must specify lat_1 or lat_0 and lon_0 for 
Albers Equal Area basemap (lat_2 is optional)'
 if lat_2 is None:
projparams['lat_2'] = lat_1
-if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]:
+if not using_corners:
 if width is None or height is None:
 raise ValueError, 'must either specify lat/lon values of 
corners (llcrnrlon,llcrnrlat,ucrnrlon,urcrnrlat) in degrees or width and height 
in meters'
 else:
@@ -354,7 +354,7 @@
 elif projection == 'stere':
 if lat_0 is None or lon_0 is None:
 raise ValueError, 'must specify lat_0 and lon_0 for 
Stereographic basemap (lat_ts is optional)'
-if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]:
+if not using_corners:
 if width is None or height is None:
 raise ValueError, 'must either specify lat/lon values of 
corners (llcrnrlon,llcrnrlat,ucrnrlon,urcrnrlat) in degrees or width and height 
in meters'
 else:
@@ -446,7 +446,7 @@
 elif projection == 'laea':
 if lat_0 is None or lon_0 is None:
 raise ValueError, 'must specify lat_0 and lon_0 for Lambert 
Azimuthal basemap'
-if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]:
+if not using_corners:
 if width is None or height is None:
 raise ValueError, 'must either specify lat/lon values of 
corners (llcrnrlon,llcrnrlat,ucrnrlon,urcrnrlat) in degrees or width and height 
in meters'
 else:
@@ -460,7 +460,7 @@
 raise ValueError, 'must specify lat_ts for Mercator basemap'
 # clip plot region to be within -89.99S to 89.99N
 # (mercator is singular at poles)
-if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]:
+if not using_corners:
 llcrnrlon = -180.
 llcrnrlat = -90.
 urcrnrlon = 180
@@ -476,7 +476,7 @@
 elif projection in ['tmerc','gnom','cass','poly'] :
 if lat_0 is None or lon_0 is None:
 raise ValueError, 'must specify lat_0 and lon_0 for Transverse 
Mercator, Gnomonic, Cassini-Soldnerr Polyconic basemap'
-if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]:
+if not using_corners:
 if width is None or height is None:
 raise ValueError, 'must either specify lat/lon values of 
corners (llcrnrlon,llcrnrlat,uc

SF.net SVN: matplotlib: [4372] trunk/toolkits/basemap-testing/lib/ matplotlib/toolkits/basemap/basemap.py

2007-11-18 Thread jswhit
Revision: 4372
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4372&view=rev
Author:   jswhit
Date: 2007-11-18 08:16:15 -0800 (Sun, 18 Nov 2007)

Log Message:
---
add 'f' to coastline resolutions. Reformat unsupported projection message.

Modified Paths:
--
trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py

Modified: 
trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py
===
--- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-18 14:31:06 UTC (rev 4371)
+++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-18 16:16:15 UTC (rev 4372)
@@ -72,7 +72,7 @@
  but if they are not, the entire globe is plotted.
 
  resolution - resolution of boundary database to use. Can be 'c' (crude),
-  'l' (low), 'i' (intermediate), 'h' (high), or None. Default is 'c'.
+  'l' (low), 'i' (intermediate), 'h' (high), 'f' (full) or None. 
   If None, no boundary data will be read in (and class methods
   such as drawcoastlines will raise an exception if invoked).
   Resolution drops off by roughly 80%
@@ -83,8 +83,8 @@
   Tools (http://gmt.soest.hawaii.edu).
 
  area_thresh - coastline or lake with an area smaller than area_thresh
-  in km^2 will not be plotted.  Default 1,1000,100,10 for resolution
-  'c','l','i','h'.
+  in km^2 will not be plotted.  Default 1,1000,100,10,1 for resolution
+  'c','l','i','h','f'.
 
  rsphere - radius of the sphere used to define map projection (default
   6370997 meters, close to the arithmetic mean radius of the earth). If
@@ -142,28 +142,8 @@
   latitude circle boundinglat is tangent to the edge of the map at lon_0.
  satellite_height - height of satellite (in m) above equator -
   only relevant for geostationary projections ('geos').
-
-
 """
 
-_unsupported_projection = """
-  unsupported projection, use 'cyl' - cylindrical equidistant, 'merc' -
-  mercator, 'lcc' - lambert conformal conic, 'stere' - stereographic,
-  'npstere' - stereographic, special case centered on north pole.
-  'spstere' - stereographic, special case centered on south pole,
-  'aea' - albers equal area conic, 'tmerc' - transverse mercator,
-  'aeqd' - azimuthal equidistant, 'mill' - miller cylindrical,
-  'npaeqd' - azimuthal equidistant, special case centered on north pole,
-  'spaeqd' - azimuthal equidistant, special case centered on south pole,
-  'eqdc' - equidistant conic, 'laea' - lambert azimuthal equal area,
-  'nplaea' - lambert azimuthal, special case centered on north pole,
-  'splaea' - lambert azimuthal, special case centered on south pole,
-  'cass' - cassini-soldner (transverse cylindrical equidistant),
-  'poly' - polyconic, 'omerc' - oblique mercator, 'ortho' - orthographic,
-  'geos' - geostationary, 'sinu' - sinusoidal, 'moll' - mollweide,
-  'robin' - robinson, or 'gnom' - gnomonic.  You tried '%s'
-  """
-
 # This allows substitution of longer names into error messages.
 projnames = {'cyl'  : 'Cylindrical Equidistant',
  'merc' : 'Mercator',
@@ -180,7 +160,7 @@
  'spaeqd'   : 'South-Polar Azimuthal Equidistant',
  'aea'  : 'Albers Equal Area',
  'stere': 'Stereographic',
- 'npstere'  : 'Nouth-Polar Stereographic',
+ 'npstere'  : 'North-Polar Stereographic',
  'spstere'  : 'South-Polar Stereographic',
  'cass' : 'Cassini-Soldner',
  'poly' : 'Polyconic',
@@ -192,6 +172,12 @@
  'gnom' : 'Gnomonic',
  }
 
+_unsupported_projection = ["'%s' is an unsupported projection.\n"]
+_unsupported_projection.append("The supported projections are:\n")
+for k,v in projnames.iteritems(): 
+ _unsupported_projection.append("'%s' = %s\n" % (k,v))
+_unsupported_projection = ''.join(_unsupported_projection)
+
 def _validated_ll(param, name, minval, maxval):
 param = float(param)
 if param > maxval or param < minval:
@@ -650,13 +636,14 @@
 
 def _readboundarydata(self,name):
 """
-read boundary data, clip to map projection region
+read boundary data, clip to map projection region.
 """
-msg = """
-Unable to open boundary dataset file. Only the 'crude', 'low',
-'intermediate' and 'high' resolution datasets are installed by default. If you
-are requesting a 'full' resolution dataset, you need to download 
-and install those files separately(see the basemap README for details)."""
+msg = dedent("""
+Unable to open boundary dataset file. Only the 'crude', 'low',
+'intermediate' and 'high' resolution datasets are installed by default.
+If you are requesting a 'full' resolution dataset, you may need to 
+download and install those files separately
+(see the basemap README for details).""")
 try:
 bdatfile = 
open(os.pa

SF.net SVN: matplotlib: [4373] trunk/toolkits/basemap-testing/lib/ matplotlib/toolkits/basemap/basemap.py

2007-11-18 Thread jswhit
Revision: 4373
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4373&view=rev
Author:   jswhit
Date: 2007-11-18 08:45:28 -0800 (Sun, 18 Nov 2007)

Log Message:
---
further streamlining of docstrings

Modified Paths:
--
trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py

Modified: 
trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py
===
--- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-18 16:16:15 UTC (rev 4372)
+++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-18 16:45:28 UTC (rev 4373)
@@ -21,6 +21,38 @@
 
 __version__ = '0.9.7'
 
+# supported map projections.
+projnames = {'cyl'  : 'Cylindrical Equidistant',
+ 'merc' : 'Mercator',
+ 'tmerc': 'Transverse Mercator',
+ 'omerc': 'Oblique Mercator',
+ 'mill' : 'Miller Cylindrical',
+ 'lcc'  : 'Lambert Conformal',
+ 'laea' : 'Lambert Azimuthal Equal Area',
+ 'nplaea'   : 'North-Polar Lambert Azimuthal',
+ 'splaea'   : 'South-Polar Lambert Azimuthal',
+ 'eqdc' : 'Equidistant Conic',
+ 'aeqd' : 'Azimuthal Equidistant',
+ 'npaeqd'   : 'North-Polar Azimuthal Equidistant',
+ 'spaeqd'   : 'South-Polar Azimuthal Equidistant',
+ 'aea'  : 'Albers Equal Area',
+ 'stere': 'Stereographic',
+ 'npstere'  : 'North-Polar Stereographic',
+ 'spstere'  : 'South-Polar Stereographic',
+ 'cass' : 'Cassini-Soldner',
+ 'poly' : 'Polyconic',
+ 'ortho': 'Orthographic',
+ 'geos' : 'Geostationary',
+ 'sinu' : 'Sinusoidal',
+ 'moll' : 'Mollweide',
+ 'robin': 'Robinson',
+ 'gnom' : 'Gnomonic',
+ }
+supported_projections = []
+for k,v in projnames.iteritems(): 
+ supported_projections.append("'%s' = %s\n" % (k,v))
+supported_projections = ''.join(supported_projections)
+
 # The __init__ docstring is pulled out here because it is so long;
 # Having it in the usual place makes it hard to get from the
 # __init__ argument list to the code that uses the arguments.
@@ -29,21 +61,8 @@
 
  arguments:
 
- projection - map projection.  'cyl' - cylindrical equidistant, 'merc' -
-  mercator, 'lcc' - lambert conformal conic, 'stere' - stereographic,
-  'npstere' - stereographic, special case centered on north pole.
-  'spstere' - stereographic, special case centered on south pole,
-  'aea' - albers equal area conic, 'tmerc' - transverse mercator,
-  'aeqd' - azimuthal equidistant, 'mill' - miller cylindrical,
-  'npaeqd' - azimuthal equidistant, special case centered on north pole,
-  'spaeqd' - azimuthal equidistant, special case centered on south pole,
-  'eqdc' - equidistant conic, 'laea' - lambert azimuthal equal area,
-  'nplaea' - lambert azimuthal, special case centered on north pole,
-  'splaea' - lambert azimuthal, special case centered on south pole,
-  'cass' - cassini-soldner (transverse cylindrical equidistant),
-  'poly' - polyconic, 'omerc' - oblique mercator, 'ortho' - orthographic,
-  'sinu' - sinusoidal, 'moll' - mollweide, 'robin' - robinson,
-  'geos' - geostationary, and 'gnom' - gnomonic are currently available.
+ projection - map projection. Supported projections are:\n"""+\
+supported_projections+"""
   Default is 'cyl'.
 
  The map projection region can either be specified by setting these keywords:
@@ -142,40 +161,12 @@
   latitude circle boundinglat is tangent to the edge of the map at lon_0.
  satellite_height - height of satellite (in m) above equator -
   only relevant for geostationary projections ('geos').
-"""
+"""
 
-# This allows substitution of longer names into error messages.
-projnames = {'cyl'  : 'Cylindrical Equidistant',
- 'merc' : 'Mercator',
- 'tmerc': 'Transverse Mercator',
- 'omerc': 'Oblique Mercator',
- 'mill' : 'Miller Cylindrical',
- 'llc'  : 'Lambert Conformal',
- 'laea' : 'Lambert Azimuthal Equal Area',
- 'nplaea'   : 'North-Polar Lambert Azimuthal',
- 'splaea'   : 'South-Polar Lambert Azimuthal',
- 'eqdc' : 'Equidistant Conic',
- 'eaqd' : 'Azimuthal Equidistant',
- 'npaeqd'   : 'North-Polar Azimuthal Equidistant',
- 'spaeqd'   : 'South-Polar Azimuthal Equidistant',
- 'aea'  : 'Albers Equal Area',
- 'stere': 'Stereographic',
- 'npstere'  : 'North-Polar Stereographic',
- 'spstere'  : 'South-Polar Stereographic',
- 'cass' : 'Cassini-Soldner',
- 'poly' : 'Polyconic',
- 'ort

SF.net SVN: matplotlib: [4374] trunk/matplotlib/lib/matplotlib/cm.py

2007-11-18 Thread efiring
Revision: 4374
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4374&view=rev
Author:   efiring
Date: 2007-11-18 10:59:56 -0800 (Sun, 18 Nov 2007)

Log Message:
---
Let to_rgba return uint8; track changes to cmap

Images require rgba as 4 uint8s, so it is more efficient
to generate these directly in to_rgba than to generate 4
doubles and convert them later.

The tracking of changes in ScalarMappable was handling
communication between objects, but was not keeping track of
when to_rgba needs to be rerun.  A dictionary was added
to do this.

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/cm.py

Modified: trunk/matplotlib/lib/matplotlib/cm.py
===
--- trunk/matplotlib/lib/matplotlib/cm.py   2007-11-18 16:45:28 UTC (rev 
4373)
+++ trunk/matplotlib/lib/matplotlib/cm.py   2007-11-18 18:59:56 UTC (rev 
4374)
@@ -40,6 +40,7 @@
 self.cmap = cmap
 self.observers = []
 self.colorbar = None
+self.update_dict = {'array':False}
 
 def set_colorbar(self, im, ax):
 'set the colorbar image and axes associated with mappable'
@@ -47,11 +48,26 @@
 
 def to_rgba(self, x, alpha=1.0, bytes=False):
 '''Return a normalized rgba array corresponding to x.
-If x is already an rgb or rgba array, return it unchanged.
+If x is already an rgb array, insert alpha; if it is
+already rgba, return it unchanged.
+If bytes is True, return rgba as 4 uint8s instead of 4 floats.
 '''
 try:
-if x.ndim == 3 and (x.shape[2] == 3 or x.shape[2] == 4):
-return x
+if x.ndim == 3:
+if x.shape[2] == 3:
+if x.dtype == npy.uint8:
+alpha = npy.array(alpha*255, npy.uint8)
+m, n = npy.shape[:2]
+xx = npy.empty(shape=(m,n,4), dtype = x.dtype)
+xx[:,:,:3] = x
+xx[:,:,3] = alpha
+elif x.shape[2] == 4:
+xx = x
+else:
+raise ValueError("third dimension must be 3 or 4")
+if bytes and xx.dtype != npy.uint8:
+xx = (xx * 255).astype(npy.uint8)
+return xx
 except AttributeError:
 pass
 x = ma.asarray(x)
@@ -62,6 +78,7 @@
 def set_array(self, A):
 'Set the image array from numpy array A'
 self._A = A
+self.update_dict['array'] = True
 
 def get_array(self):
 'Return the array'
@@ -124,7 +141,23 @@
 self.changed()
 
 
+def add_checker(self, checker):
+"""
+Add an entry to a dictionary of boolean flags
+that are set to True when the mappable is changed.
+"""
+self.update_dict[checker] = False
 
+def check_update(self, checker):
+"""
+If mappable has changed since the last check,
+return True; else return False
+"""
+if self.update_dict[checker]:
+self.update_dict[checker] = False
+return True
+return False
+
 def add_observer(self, mappable):
 """
 whenever the norm, clim or cmap is set, call the notify
@@ -158,3 +191,6 @@
 """
 for observer in self.observers:
 observer.notify(self)
+for key in self.update_dict:
+self.update_dict[key] = True
+


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 2005.
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: [4375] trunk/matplotlib/src/_backend_agg.cpp

2007-11-18 Thread efiring
Revision: 4375
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4375&view=rev
Author:   efiring
Date: 2007-11-18 11:01:39 -0800 (Sun, 18 Nov 2007)

Log Message:
---
Remove trailing whitespace.

Modified Paths:
--
trunk/matplotlib/src/_backend_agg.cpp

Modified: trunk/matplotlib/src/_backend_agg.cpp
===
--- trunk/matplotlib/src/_backend_agg.cpp   2007-11-18 18:59:56 UTC (rev 
4374)
+++ trunk/matplotlib/src/_backend_agg.cpp   2007-11-18 19:01:39 UTC (rev 
4375)
@@ -46,10 +46,10 @@
 
 GCAgg::GCAgg(const Py::Object &gc, double dpi, bool snapto) :
   dpi(dpi), snapto(snapto), isaa(true), linewidth(1.0), alpha(1.0),
-  cliprect(NULL), clippath(NULL), 
+  cliprect(NULL), clippath(NULL),
   Ndash(0), dashOffset(0.0), dasha(NULL)
 {
-  
+
   _VERBOSE("GCAgg::GCAgg");
   linewidth = points_to_pixels ( gc.getAttr("_linewidth") ) ;
   alpha = Py::Float( gc.getAttr("_alpha") );
@@ -66,16 +66,16 @@
 GCAgg::_set_antialiased(const Py::Object& gc) {
   _VERBOSE("GCAgg::antialiased");
   isaa = Py::Int( gc.getAttr( "_antialiased") );
-  
+
 }
 
 agg::rgba
 GCAgg::get_color(const Py::Object& gc) {
   _VERBOSE("GCAgg::get_color");
   Py::Tuple rgb = Py::Tuple( gc.getAttr("_rgb") );
-  
+
   double alpha = Py::Float( gc.getAttr("_alpha") );
-  
+
   double r = Py::Float(rgb[0]);
   double g = Py::Float(rgb[1]);
   double b = Py::Float(rgb[2]);
@@ -93,9 +93,9 @@
 void
 GCAgg::_set_linecap(const Py::Object& gc) {
   _VERBOSE("GCAgg::_set_linecap");
-  
+
   std::string capstyle = Py::String( gc.getAttr( "_capstyle" ) );
-  
+
   if (capstyle=="butt")
 cap = agg::butt_cap;
   else if (capstyle=="round")
@@ -104,15 +104,15 @@
 cap = agg::square_cap;
   else
 throw Py::ValueError(Printf("GC _capstyle attribute must be one of butt, 
round, projecting; found %s", capstyle.c_str()).str());
-  
+
 }
 
 void
 GCAgg::_set_joinstyle(const Py::Object& gc) {
   _VERBOSE("GCAgg::_set_joinstyle");
-  
+
   std::string joinstyle = Py::String( gc.getAttr("_joinstyle") );
-  
+
   if (joinstyle=="miter")
 join =  agg::miter_join;
   else if (joinstyle=="round")
@@ -121,35 +121,35 @@
 join = agg::bevel_join;
   else
 throw Py::ValueError(Printf("GC _joinstyle attribute must be one of butt, 
round, projecting; found %s", joinstyle.c_str()).str());
-  
+
 }
 
 void
 GCAgg::_set_dashes(const Py::Object& gc) {
   //return the dashOffset, dashes sequence tuple.
   _VERBOSE("GCAgg::_set_dashes");
-  
+
   delete [] dasha;
   dasha = NULL;
-  
+
   Py::Tuple dashtup = gc.getAttr("_dashes");
-  
+
   if (dashtup.length()!=2)
 throw Py::ValueError(Printf("GC dashtup must be a length 2 tuple; found 
%d", dashtup.length()).str());
-  
-  
+
+
   bool useDashes = dashtup[0].ptr() != Py_None;
-  
+
   if ( !useDashes ) return;
-  
+
   dashOffset = points_to_pixels(dashtup[0]);
   Py::SeqBase dashSeq;
   dashSeq = dashtup[1];
-  
+
   Ndash = dashSeq.length();
   if (Ndash%2 != 0  )
 throw Py::ValueError(Printf("dash sequence must be an even length 
sequence; found %d", Ndash).str());
-  
+
   dasha = new double[Ndash];
   double val;
   for (size_t i=0; i rect( o );
-  
+
   double l = Py::Float(rect[0]) ;
   double b = Py::Float(rect[1]) ;
   double w = Py::Float(rect[2]) ;
   double h = Py::Float(rect[3]) ;
-  
+
   cliprect = new double[4];
   //todo check for memory alloc failure
   cliprect[0] = l;
@@ -192,24 +192,24 @@
 void
 GCAgg::_set_clip_path( const Py::Object& gc) {
   //set the clip path from the gc
-  
+
   _VERBOSE("GCAgg::_set_clip_path");
-  
+
   delete clippath;
   clippath = NULL;
-  
+
   Py::Object o  = gc.getAttr( "_clippath" );
   if (o.ptr()==Py_None) {
 return;
   }
-  
+
   agg::path_storage *tmppath;
   swig_type_info * descr = SWIG_TypeQuery("agg::path_storage *");
   assert(descr);
   if (SWIG_ConvertPtr(o.ptr(),(void **)(&tmppath), descr, 0) == -1) {
 throw Py::TypeError("Could not convert gc path_storage");
   }
-  
+
   tmppath->rewind(0);
   clippath = new agg::path_storage();
   clippath->copy_from(*tmppath);
@@ -219,7 +219,7 @@
 
 
 Py::Object BufferRegion::to_string(const Py::Tuple &args) {
-  
+
   // owned=true to prevent memory leak
   return Py::String(PyString_FromStringAndSize((const 
char*)aggbuf.data,aggbuf.height*aggbuf.stride), true);
 }
@@ -241,12 +241,12 @@
 {
   _VERBOSE("RendererAgg::RendererAgg");
   unsigned stride(width*4);
-  
-  
+
+
   pixBuffer = new agg::int8u[NUMBYTES];
   renderingBuffer = new agg::rendering_buffer;
   renderingBuffer->attach(pixBuffer, width, height, stride);
-  
+
   alphaBuffer = new agg::int8u[NUMBYTES];
   alphaMaskRenderingBuffer = new agg::rendering_buffer;
   alphaMaskRenderingBuffer->attach(alphaBuffer, width, height, stride);
@@ -256,22 +256,22 @@
   rendererBaseAlphaMask = new renderer_base_alpha_mask_type(*pixfmtAlphaMask);
   rendererAlphaMask = new renderer_alpha_mask_type(*rendererBaseAlphaMask);
   scanlineAlphaMa

SF.net SVN: matplotlib: [4376] trunk/matplotlib/lib/matplotlib/collections. py

2007-11-18 Thread efiring
Revision: 4376
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4376&view=rev
Author:   efiring
Date: 2007-11-18 11:02:55 -0800 (Sun, 18 Nov 2007)

Log Message:
---
Use new update_dict from ScalarMappable in QuadMesh

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/collections.py

Modified: trunk/matplotlib/lib/matplotlib/collections.py
===
--- trunk/matplotlib/lib/matplotlib/collections.py  2007-11-18 19:01:39 UTC 
(rev 4375)
+++ trunk/matplotlib/lib/matplotlib/collections.py  2007-11-18 19:02:55 UTC 
(rev 4376)
@@ -322,15 +322,14 @@
 return self._coordinates;
 
 def draw(self, renderer):
-# does not call update_scalarmappable, need to update it
-# when creating/changing  ** Why not?  speed?
 if not self.get_visible(): return
 transform = self.get_transform()
 transoffset = self.get_transoffset()
 transform.freeze()
 transoffset.freeze()
 #print 'QuadMesh draw'
-self.update_scalarmappable()  ###
+if self.check_update('array'):
+self.update_scalarmappable()
 
 renderer.draw_quad_mesh( self._meshWidth, self._meshHeight,
 self._facecolors, self._coordinates[:,0],
@@ -797,7 +796,7 @@
 
 self._lw = self._get_value(lw)
 set_linewidths = set_lw = set_linewidth
-
+
 def set_linestyle(self, ls):
 """
 Set the linestyles(s) for the collection.


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 2005.
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: [4377] trunk/matplotlib/lib/matplotlib

2007-11-18 Thread efiring
Revision: 4377
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4377&view=rev
Author:   efiring
Date: 2007-11-18 11:06:49 -0800 (Sun, 18 Nov 2007)

Log Message:
---
Add experimental "pcolorfast" for fast interactive pcolor plots

This will need more discussion and work, but it illustrates
the potential for very fast pcolor-type plotting with all
three grid types: uniform, irregular but rectilinear, and
general quadrilateral.

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/image.py

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2007-11-18 19:02:55 UTC (rev 
4376)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2007-11-18 19:06:49 UTC (rev 
4377)
@@ -3706,8 +3706,8 @@
 xs = [thisx for thisx, b in zip(xs, mask) if b]
 ys = [thisy for thisy, b in zip(ys, mask) if b]
 return xs, ys
-
 
+
 if capsize > 0:
 plot_kw = {
 'ms':2*capsize,
@@ -3733,16 +3733,16 @@
 # can't use numpy logical indexing since left and
 # y are lists
 leftlo, ylo = xywhere(left, y, xlolims)
-
+
 caplines.extend( self.plot(leftlo, ylo, ls='None', 
marker=mlines.CARETLEFT, **plot_kw) )
 xlolims = ~xlolims
-leftlo, ylo = xywhere(left, y, xlolims)
+leftlo, ylo = xywhere(left, y, xlolims)
 caplines.extend( self.plot(leftlo, ylo, 'k|', **plot_kw) )
 else:
 caplines.extend( self.plot(left, y, 'k|', **plot_kw) )
 
 if xuplims.any():
-
+
 rightup, yup = xywhere(right, y, xuplims)
 caplines.extend( self.plot(rightup,  yup, ls='None', 
marker=mlines.CARETRIGHT, **plot_kw) )
 xuplims = ~xuplims
@@ -3775,7 +3775,7 @@
 
 if uplims.any():
 xup, upperup = xywhere(x, upper, uplims)
-
+
 caplines.extend( self.plot(xup, upperup, ls='None', 
marker=mlines.CARETUP, **plot_kw) )
 uplims = ~uplims
 xup, upperup = xywhere(x, upper, uplims)
@@ -4762,6 +4762,177 @@
 return collection
 pcolormesh.__doc__ = cbook.dedent(pcolormesh.__doc__) % martist.kwdocd
 
+def pcolorfast(self, *args, **kwargs):
+"""
+Experimental; this is a version of pcolor that
+does not draw lines, that provides the fastest
+possible rendering with the Agg backend, and that
+can handle any quadrilateral grid.
+
+pcolor(*args, **kwargs): pseudocolor plot of a 2-D array
+
+Function signatures
+
+  pcolor(C, **kwargs)
+  pcolor(xr, yr, C, **kwargs)
+  pcolor(x, y, C, **kwargs)
+  pcolor(X, Y, C, **kwargs)
+
+C is the 2D array of color values corresponding to quadrilateral
+cells. Let (nr, nc) be its shape.  C may be a masked array.
+
+pcolor(C, **kwargs) is equivalent to
+pcolor([0,nc], [0,nr], C, **kwargs)
+
+xr, yr specify the ranges of x and y corresponding to the rectangular
+region bounding C.  If xr = [x0, x1] and yr = [y0,y1] then
+x goes from x0 to x1 as the second index of C goes from 0 to nc,
+etc.  (x0, y0) is the outermost corner of cell (0,0), and (x1, y1)
+is the outermost corner of cell (nr-1, nc-1).  All cells are
+rectangles of the same size.  This is the fastest version.
+
+x, y are 1D arrays of length nc+1 and nr+1, respectively, giving
+the x and y boundaries of the cells.  Hence the cells are
+rectangular but the grid may be nonuniform.  The speed is
+intermediate.  (The grid is checked, and if found to be
+uniform the fast version is used.)
+
+X and Y are 2D arrays with shape (nr+1, nc+1) that specify
+the (x,y) coordinates of the corners of the colored
+quadrilaterals; the quadrilateral for C[i,j] has corners at
+(X[i,j],Y[i,j]), (X[i,j+1],Y[i,j+1]), (X[i+1,j],Y[i+1,j]),
+(X[i+1,j+1],Y[i+1,j+1]).  The cells need not be rectangular.
+This is the most general, but the slowest to render.  It may
+produce faster and more compact output using ps, pdf, and
+svg backends, however.
+
+Note that the the column index corresponds to the x-coordinate,
+and the row index corresponds to y; for details, see
+the "Grid Orientation" section below.
+
+Optional keyword args are shown with their defaults below (you must
+use kwargs for these):
+
+  * cmap = cm.jet : a cm Colormap instance from cm
+
+  * norm = Normalize() : mcol

SF.net SVN: matplotlib: [4378] trunk/toolkits/basemap-testing/lib/ matplotlib/toolkits/basemap/basemap.py

2007-11-18 Thread jswhit
Revision: 4378
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4378&view=rev
Author:   jswhit
Date: 2007-11-18 11:28:13 -0800 (Sun, 18 Nov 2007)

Log Message:
---
more docstring tweaks

Modified Paths:
--
trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py

Modified: 
trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py
===
--- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-18 19:06:49 UTC (rev 4377)
+++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py   
2007-11-18 19:28:13 UTC (rev 4378)
@@ -22,7 +22,7 @@
 __version__ = '0.9.7'
 
 # supported map projections.
-projnames = {'cyl'  : 'Cylindrical Equidistant',
+_projnames = {'cyl'  : 'Cylindrical Equidistant',
  'merc' : 'Mercator',
  'tmerc': 'Transverse Mercator',
  'omerc': 'Oblique Mercator',
@@ -49,7 +49,7 @@
  'gnom' : 'Gnomonic',
  }
 supported_projections = []
-for k,v in projnames.iteritems(): 
+for k,v in _projnames.iteritems(): 
  supported_projections.append("'%s' = %s\n" % (k,v))
 supported_projections = ''.join(supported_projections)
 
@@ -191,9 +191,7 @@
 Useful instance variables:
 
 projection - map projection. Print the module variable
-"supported_projections" to see a list.
-(projections prefixed with 'np' or 'sp' are special case polar-centric
- versions of the parent projection)
+"supported_projections" to see a list of supported projections.
 aspect - map aspect ratio (size of y dimension / size of x dimension).
 llcrnrlon - longitude of lower left hand corner of the desired map domain.
 llcrnrlon - latitude of lower left hand corner of the desired map domain.
@@ -301,7 +299,7 @@
 lat_1 = lat_0
 projparams['lat_1'] = lat_1
 if lat_1 is None or lon_0 is None:
-raise ValueError('must specify lat_1 or lat_0 and lon_0 for 
%(projection)s basemap (lat_2 is optional)' % projnames)
+raise ValueError('must specify lat_1 or lat_0 and lon_0 for 
%(projection)s basemap (lat_2 is optional)' % _projnames)
 if lat_2 is None:
projparams['lat_2'] = lat_1
 if not using_corners:
@@ -330,7 +328,7 @@
 'splaea', 'nplaea',
 'spaeqd', 'npaeqd']:
 if boundinglat is None or lon_0 is None:
-raise ValueError('must specify boundinglat and lon_0 for 
%(projection) basemap' % projnames)
+raise ValueError('must specify boundinglat and lon_0 for 
%(projection) basemap' % _projnames)
 if projection[0] == 's':
 sgn = -1
 else:


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 2005.
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: [4379] trunk/matplotlib/src/_backend_agg.cpp

2007-11-18 Thread efiring
Revision: 4379
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4379&view=rev
Author:   efiring
Date: 2007-11-18 12:54:22 -0800 (Sun, 18 Nov 2007)

Log Message:
---
Remove unnecessary data copying from draw_quad_mesh

Modified Paths:
--
trunk/matplotlib/src/_backend_agg.cpp

Modified: trunk/matplotlib/src/_backend_agg.cpp
===
--- trunk/matplotlib/src/_backend_agg.cpp   2007-11-18 19:28:13 UTC (rev 
4378)
+++ trunk/matplotlib/src/_backend_agg.cpp   2007-11-18 20:54:22 UTC (rev 
4379)
@@ -1052,7 +1052,8 @@
   }
 
   set_clip_from_bbox(args[5]);
-
+  // Does it make sense to support offsets in QuadMesh?
+  // When would they be used?
   Py::SeqBase offsets;
   Transformation* transOffset = NULL;
   bool usingOffsets = args[7].ptr() != Py_None;
@@ -1079,19 +1080,12 @@
   std::pair xyo, xy;
 
   //do non-offset transformations
-  double* xCoordsa = new double[Nverts];
-  double* yCoordsa = new double[Nverts];
   double* newXCoords = new double[Nverts];
   double* newYCoords = new double[Nverts];
   size_t k, q;
-  for(k=0; k < Nverts; k++)
-{
-  xCoordsa[k] = *(double *)(xCoords -> data + k*(xCoords -> strides[0]));
-  yCoordsa[k] = *(double *)(yCoords -> data + k*(yCoords -> strides[0]));
-}
-  transform->arrayOperator(Nverts, xCoordsa, yCoordsa, newXCoords, newYCoords);
-  delete xCoordsa;
-  delete yCoordsa;
+  transform->arrayOperator(Nverts, (const double *)xCoords->data,
+(const double *)yCoords->data,
+newXCoords, newYCoords);
   if(usingOffsets)
 {
   double* xOffsets = new double[Noffsets];
@@ -1099,17 +1093,17 @@
   double* newXOffsets = new double[Noffsets];
   double* newYOffsets = new double[Noffsets];
   for(k=0; k < Noffsets; k++)
-   {
- Py::SeqBase pos = Py::SeqBase(offsets[k]);
- xOffsets[k] = Py::Float(pos[0]);
- yOffsets[k] = Py::Float(pos[1]);
-   }
+{
+  Py::SeqBase pos = Py::SeqBase(offsets[k]);
+  xOffsets[k] = Py::Float(pos[0]);
+  yOffsets[k] = Py::Float(pos[1]);
+}
   transOffset->arrayOperator(Noffsets, xOffsets, yOffsets, newXOffsets, 
newYOffsets);
   for(k=0; k < Nverts; k++)
-   {
- newXCoords[k] += newXOffsets[k];
- newYCoords[k] += newYOffsets[k];
-   }
+{
+  newXCoords[k] += newXOffsets[k];
+  newYCoords[k] += newYOffsets[k];
+}
   delete xOffsets;
   delete yOffsets;
   delete newXOffsets;


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 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins