You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <js...@us...> - 2007-11-20 04:09:56
|
Revision: 4386 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4386&view=rev Author: jswhit Date: 2007-11-19 20:09:55 -0800 (Mon, 19 Nov 2007) Log Message: ----------- added lake_color keyword to fillcontinents Modified Paths: -------------- trunk/toolkits/basemap-testing/Changelog Modified: trunk/toolkits/basemap-testing/Changelog =================================================================== --- trunk/toolkits/basemap-testing/Changelog 2007-11-20 04:08:52 UTC (rev 4385) +++ trunk/toolkits/basemap-testing/Changelog 2007-11-20 04:09:55 UTC (rev 4386) @@ -1,4 +1,5 @@ version 0.9.7 (not yet released) + * added lake_color keyword to fillcontinents. * fixed a bug in the 'tmerc' projection. * added pure python NetCDFFile reader from Roberto De Almeida to basemap namespace This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-20 04:09:02
|
Revision: 4385 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4385&view=rev Author: jswhit Date: 2007-11-19 20:08:52 -0800 (Mon, 19 Nov 2007) Log Message: ----------- change outerproduct to outer Modified Paths: -------------- trunk/toolkits/basemap-testing/examples/show_colormaps.py Modified: trunk/toolkits/basemap-testing/examples/show_colormaps.py =================================================================== --- trunk/toolkits/basemap-testing/examples/show_colormaps.py 2007-11-20 02:37:12 UTC (rev 4384) +++ trunk/toolkits/basemap-testing/examples/show_colormaps.py 2007-11-20 04:08:52 UTC (rev 4385) @@ -1,16 +1,16 @@ -from pylab import * +import numpy, pylab from matplotlib.toolkits.basemap import cm -a=outerproduct(arange(0,1,0.01),ones(10)) -figure(figsize=(10,7)) -subplots_adjust(top=0.8,bottom=0.05,left=0.01,right=0.99) +a=numpy.outer(numpy.arange(0,1,0.01),numpy.ones(10)) +pylab.figure(figsize=(10,7)) +pylab.subplots_adjust(top=0.8,bottom=0.05,left=0.01,right=0.99) maps=[m for m in cm.datad.keys() if not m.endswith("_r")] maps.sort() l=len(maps)+1 i=1 for m in maps: - subplot(1,l,i) - axis("off") - imshow(a,aspect='auto',cmap=cm.__dict__[m],origin="lower") - title(m,rotation=90,fontsize=10) + pylab.subplot(1,l,i) + pylab.axis("off") + pylab.imshow(a,aspect='auto',cmap=cm.__dict__[m],origin="lower") + pylab.title(m,rotation=90,fontsize=10) i=i+1 -show() +pylab.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-20 02:37:13
|
Revision: 4384 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4384&view=rev Author: jswhit Date: 2007-11-19 18:37:12 -0800 (Mon, 19 Nov 2007) Log Message: ----------- lake_color keyword arg to fill continents added 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-19 21:43:24 UTC (rev 4383) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-20 02:37:12 UTC (rev 4384) @@ -991,11 +991,12 @@ # set axes limits to fit map region. self.set_axes_limits(ax=ax) - def fillcontinents(self,color='0.8',ax=None,zorder=None): + def fillcontinents(self,color='0.8',lake_color=None,ax=None,zorder=None): """ Fill continents. color - color to fill continents (default gray). + lake_color - color to fill inland lakes (default axes background). ax - axes instance (overrides default axes instance). zorder - sets the zorder for the continent polygons (if not specified, uses default zorder for a Polygon patch). Set to zero if you want to paint @@ -1038,8 +1039,11 @@ xy = zip(xa.tolist(),ya.tolist()) if self.coastpolygontypes[np] != 2: poly = Polygon(xy,facecolor=color,edgecolor=color,linewidth=0) - else: # lakes filled with background color. - poly = Polygon(xy,facecolor=axisbgc,edgecolor=axisbgc,linewidth=0) + else: # lakes filled with background color by default + if lake_color is None: + poly = Polygon(xy,facecolor=axisbgc,edgecolor=axisbgc,linewidth=0) + else: + poly = Polygon(xy,facecolor=lake_color,edgecolor=lake_color,linewidth=0) if zorder is not None: poly.set_zorder(zorder) ax.add_patch(poly) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-11-19 21:43:29
|
Revision: 4383 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4383&view=rev Author: jdh2358 Date: 2007-11-19 13:43:24 -0800 (Mon, 19 Nov 2007) Log Message: ----------- fixed a minor bug in csv2rec Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/mlab.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2007-11-19 13:17:02 UTC (rev 4382) +++ trunk/matplotlib/lib/matplotlib/axes.py 2007-11-19 21:43:24 UTC (rev 4383) @@ -3313,7 +3313,7 @@ self.hold(holdstate) # restore previous hold state if adjust_xlim: - xmin, xmax = self.dataLim.intervalx().get_bounds() + xmin, xmax = self.dataLim.intervalx().get_bounds() xmin = npy.amin(width) if xerr is not None: xmin = xmin - npy.amax(xerr) Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-11-19 13:17:02 UTC (rev 4382) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-11-19 21:43:24 UTC (rev 4383) @@ -44,7 +44,7 @@ compute it for a lot of pairs. This function is optimized to do this efficiently by caching the direct FFTs. -= record array helper functions = += record array helper functions = rec2csv : store record array in CSV file rec2excel : store record array in excel worksheet - required pyExcelerator @@ -1261,8 +1261,6 @@ def splitfunc(x): return x.split(delimiter) - - converterseq = None for i,line in enumerate(fh): if i<skiprows: continue @@ -1958,13 +1956,13 @@ newrec[name] = arr return newrec.view(npy.recarray) - + def rec_drop_fields(rec, names): - 'return a new numpy record array with fields in names dropped' + 'return a new numpy record array with fields in names dropped' names = set(names) Nr = len(rec) - + newdtype = npy.dtype([(name, rec.dtype[name]) for name in rec.dtype.names if name not in names]) @@ -1974,7 +1972,7 @@ return newrec.view(npy.recarray) - + def rec_join(key, r1, r2): """ join record arrays r1 and r2 on key; key is a tuple of field @@ -1992,15 +1990,15 @@ def makekey(row): return tuple([row[name] for name in key]) - + names = list(r1.dtype.names) + [name for name in r2.dtype.names if name not in set(r1.dtype.names)] - - - r1d = dict([(makekey(row),i) for i,row in enumerate(r1)]) + + + r1d = dict([(makekey(row),i) for i,row in enumerate(r1)]) r2d = dict([(makekey(row),i) for i,row in enumerate(r2)]) - r1keys = set(r1d.keys()) + r1keys = set(r1d.keys()) r2keys = set(r2d.keys()) keys = r1keys & r2keys @@ -2008,7 +2006,7 @@ r1ind = [r1d[k] for k in keys] r2ind = [r2d[k] for k in keys] - + r1 = r1[r1ind] r2 = r2[r2ind] @@ -2028,15 +2026,15 @@ else: return (name, dt2.descr[0][1]) - - + + keydesc = [key_desc(name) for name in key] newdtype = npy.dtype(keydesc + [desc for desc in r1.dtype.descr if desc[0] not in key ] + [desc for desc in r2.dtype.descr if desc[0] not in key ] ) - - + + newrec = npy.empty(len(r1), dtype=newdtype) for field in r1.dtype.names: newrec[field] = r1[field] @@ -2089,7 +2087,7 @@ fh = cbook.to_filehandle(fname) - + class FH: """ for space delimited files, we want different behavior than @@ -2115,13 +2113,13 @@ return self.fix(self.fh.next()) def __iter__(self): - for line in self.fh: + for line in self.fh: yield self.fix(line) if delimiter==' ': fh = FH(fh) - reader = csv.reader(fh, delimiter=delimiter) + reader = csv.reader(fh, delimiter=delimiter) def process_skiprows(reader): if skiprows: for i, row in enumerate(reader): @@ -2155,7 +2153,7 @@ 'file' : 'file_', 'print' : 'print_', } - + def get_converters(reader): converters = None @@ -2209,6 +2207,7 @@ # reset the reader and start over fh.seek(0) + reader = csv.reader(fh, delimiter=delimiter) process_skiprows(reader) if needheader: skipheader = reader.next() @@ -2232,7 +2231,7 @@ class FormatObj: def tostr(self, x): return self.toval(x) - + def toval(self, x): return str(x) @@ -2255,12 +2254,12 @@ FormatFormatStr.__init__(self, '%%1.%df'%precision) self.precision = precision self.scale = scale - + def toval(self, x): if x is not None: x = x * self.scale return x - + class FormatInt(FormatObj): def toval(self, x): return x @@ -2292,20 +2291,20 @@ defaultformatd = { - npy.int16 : FormatInt(), + npy.int16 : FormatInt(), npy.int32 : FormatInt(), - npy.int64 : FormatInt(), + npy.int64 : FormatInt(), npy.float32 : FormatFloat(), - npy.float64 : FormatFloat(), + npy.float64 : FormatFloat(), npy.object_ : FormatObj(), - npy.string_ : FormatObj(), + npy.string_ : FormatObj(), } def get_formatd(r, formatd=None): 'build a formatd guaranteed to have a key for every dtype name' if formatd is None: formatd = dict() - + for i, name in enumerate(r.dtype.names): dt = r.dtype[name] format = formatd.get(name) @@ -2316,7 +2315,7 @@ def csvformat_factory(format): format = copy.deepcopy(format) - if isinstance(format, FormatFloat): + if isinstance(format, FormatFloat): format.scale = 1. # override scaling for storage format.fmt = '%g' # maximal precision return format @@ -2358,14 +2357,14 @@ """ format = copy.deepcopy(format) - - + + xlstyle = excel.XFStyle() - if isinstance(format, FormatFloat): + if isinstance(format, FormatFloat): zeros = ''.join(['0']*format.precision) xlstyle.num_format_str = '#,##0.%s;[RED]-#,##0.%s'%(zeros, zeros) elif isinstance(format, FormatInt): - xlstyle.num_format_str = '#,##;[RED]-#,##' + xlstyle.num_format_str = '#,##;[RED]-#,##' elif isinstance(format, FormatPercent): zeros = ''.join(['0']*format.precision) xlstyle.num_format_str = '0.%s%;[RED]-0.%s%'%(zeros, zeros) @@ -2374,7 +2373,7 @@ xlstyle = None format.xlstyle = xlstyle - + return format def rec2excel(r, ws, formatd=None, rownum=0): @@ -2412,7 +2411,7 @@ rownum+=1 - + ind = npy.arange(len(r.dtype.names)) for row in r: for i in ind: @@ -2470,7 +2469,7 @@ cell.set_property('foreground', 'black') - if isinstance(format, FormatFloat) or isinstance(format, FormatInt): + if isinstance(format, FormatFloat) or isinstance(format, FormatInt): format.cell = negative_red_cell format.xalign = 1. elif isinstance(format, FormatDate): @@ -2573,7 +2572,7 @@ self.clear() def clear(self): - self.iterd = dict() + self.iterd = dict() self.iters = [] # an ordered list of iters self.rownumd = dict() # a map from rownum -> symbol self.model.clear() @@ -2596,7 +2595,7 @@ thisiter = self.iterd[key] self.model.remove(thisiter) del self.datad[key] - del self.iterd[key] + del self.iterd[key] self.iters.remove(thisiter) for i, thisiter in enumerate(self.iters): @@ -2611,7 +2610,7 @@ del self.datad[key] - del self.iterd[key] + del self.iterd[key] self.rownumd[len(self.iters)] = key self.iters.remove(thisiter) @@ -2619,7 +2618,7 @@ if thiskey==key: del self.rownumd[rownum] def add_row(self, row): - thisiter = self.model.append() + thisiter = self.model.append() self.model.set(thisiter, *self.flat(row)) key = tuple(row) self.datad[key] = row @@ -2702,7 +2701,7 @@ win.add(scroll) win.show_all() scroll.win = win - + return scroll This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-19 13:17:04
|
Revision: 4382 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4382&view=rev Author: jswhit Date: 2007-11-19 05:17:02 -0800 (Mon, 19 Nov 2007) Log Message: ----------- run reindent.py Modified Paths: -------------- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/proj.py Modified: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/proj.py =================================================================== --- trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/proj.py 2007-11-19 13:14:53 UTC (rev 4381) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/proj.py 2007-11-19 13:17:02 UTC (rev 4382) @@ -341,4 +341,3 @@ assert (lons==lonlat[...,0]).all(), "The longitudes are different" assert (lats==lonlat[...,1]).all(), "The latitudes are different" - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-19 13:14:55
|
Revision: 4381 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4381&view=rev Author: jswhit Date: 2007-11-19 05:14:53 -0800 (Mon, 19 Nov 2007) Log Message: ----------- run reindent.py 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-19 13:10:49 UTC (rev 4380) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-19 13:14:53 UTC (rev 4381) @@ -49,8 +49,8 @@ 'gnom' : 'Gnomonic', } supported_projections = [] -for _items in _projnames.iteritems(): - supported_projections.append("'%s' = %s\n" % (_items)) +for _items in _projnames.iteritems(): + supported_projections.append("'%s' = %s\n" % (_items)) supported_projections = ''.join(supported_projections) # The __init__ docstring is pulled out here because it is so long; @@ -91,7 +91,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), 'f' (full) or None. + '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%% @@ -289,8 +289,8 @@ self.llcrnrlat = _validated_ll(llcrnrlat, 'llcrnrlat', -90, 90) self.urcrnrlat = _validated_ll(urcrnrlat, 'urcrnrlat', -90, 90) - # for each of the supported projections, - # compute lat/lon of domain corners + # for each of the supported projections, + # compute lat/lon of domain corners # and set values in projparams dict as needed. if projection in ['lcc', 'eqdc', 'aea']: @@ -302,7 +302,7 @@ 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) if lat_2 is None: - projparams['lat_2'] = lat_1 + projparams['lat_2'] = lat_1 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' @@ -475,7 +475,7 @@ # initialize proj4 proj = Proj(projparams,self.llcrnrlon,self.llcrnrlat,self.urcrnrlon,self.urcrnrlat) - + # make sure axis ticks are suppressed. self.noticks = suppress_ticks @@ -571,12 +571,12 @@ dist = npy.sqrt(xd+yd) split = dist > 5000000. if npy.sum(split) and self.projection not in ['merc','cyl','mill']: - ind = (npy.compress(split,squeeze(split*npy.indices(xd.shape)))+1).tolist() - iprev = 0 - ind.append(len(xd)) - for i in ind: - coastsegs.append(zip(x[iprev:i],y[iprev:i])) - iprev = i + ind = (npy.compress(split,squeeze(split*npy.indices(xd.shape)))+1).tolist() + iprev = 0 + ind.append(len(xd)) + for i in ind: + coastsegs.append(zip(x[iprev:i],y[iprev:i])) + iprev = i else: coastsegs.append(seg) self.coastsegs = coastsegs @@ -619,7 +619,7 @@ 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 + 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: @@ -649,7 +649,7 @@ # make sure orthographic projection has containsPole=True # we will compute the intersections in stereographic # coordinates, then transform to orthographic. - if self.projection == 'ortho' and name == 'gshhs': + if self.projection == 'ortho' and name == 'gshhs': containsPole = True lon_0=self.projparams['lon_0'] lat_0=self.projparams['lat_0'] @@ -674,7 +674,7 @@ offsetbytes = int(linesplit[5]) bytecount = int(linesplit[6]) bdatfile.seek(offsetbytes,0) - # read in binary string convert into an npts by 2 + # read in binary string convert into an npts by 2 # numpy array (first column is lons, second is lats). polystring = bdatfile.read(bytecount) # binary data is little endian. @@ -685,7 +685,7 @@ # coordinates (i.e. it does not contain either pole), # the intersections of the boundary geometries # and the map projection region can be computed before - # transforming the boundary geometry to map projection + # transforming the boundary geometry to map projection # coordinates (this saves time, especially for small map # regions and high-resolution boundary geometries). if not containsPole: @@ -713,7 +713,7 @@ poly = Shape(b) antart = False # create duplicate polygons shifted by -360 and +360 - # (so as to properly treat polygons that cross + # (so as to properly treat polygons that cross # Greenwich meridian). if not antart: b2[:,0] = b[:,0]-360 @@ -760,7 +760,7 @@ else: b[:,0], b[:,1] = self(b[:,0], b[:,1]) goodmask = npy.logical_and(b[:,0]<1.e20,b[:,1]<1.e20) - # if less than two points are valid in + # if less than two points are valid in # map proj coords, skip this geometry. if npy.sum(goodmask) <= 1: continue if name != 'gshhs': @@ -849,7 +849,7 @@ projparms['x_0']=-llcrnrx projparms['y_0']=-llcrnry maptran = pyproj.Proj(projparms) - elif self.projection in ['moll','robin','sinu']: + elif self.projection in ['moll','robin','sinu']: # quasi-elliptical region. lon_0 = self.projparams['lon_0'] # left side @@ -893,7 +893,7 @@ boundaryxy = _geos.Polygon(b) if self.projection in ['mill','merc','cyl']: # make sure map boundary doesn't quite include pole. - if self.urcrnrlat > 89.9999: + if self.urcrnrlat > 89.9999: urcrnrlat = 89.9999 else: urcrnrlat = self.urcrnrlat @@ -908,14 +908,14 @@ b[:,0]=x; b[:,1]=y boundaryxy = _geos.Polygon(b) else: - if self.projection not in ['moll','robin','sinu']: + if self.projection not in ['moll','robin','sinu']: lons, lats = maptran(x,y,inverse=True) # fix lons so there are no jumps. n = 1 lonprev = lons[0] for lon,lat in zip(lons[1:],lats[1:]): if npy.abs(lon-lonprev) > 90.: - if lonprev < 0: + if lonprev < 0: lon = lon - 360. else: lon = lon + 360 @@ -1004,7 +1004,7 @@ After filling continents, lakes are re-filled with axis background color. """ if self.resolution is None: - raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' + raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' # get current axes instance (if none specified). if ax is None and self.ax is None: try: @@ -1059,7 +1059,7 @@ uses default zorder for LineCollections). """ if self.resolution is None: - raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' + raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' # get current axes instance (if none specified). if ax is None and self.ax is None: try: @@ -1090,7 +1090,7 @@ uses default zorder for LineCollections). """ if self.resolution is None: - raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' + raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' # read in country line segments, only keeping those that # intersect map boundary polygon. if not hasattr(self,'cntrysegs'): @@ -1125,7 +1125,7 @@ uses default zorder for LineCollections). """ if self.resolution is None: - raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' + raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' # read in state line segments, only keeping those that # intersect map boundary polygon. if not hasattr(self,'statesegs'): @@ -1160,7 +1160,7 @@ uses default zorder for LineCollections). """ if self.resolution is None: - raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' + raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' # read in river line segments, only keeping those that # intersect map boundary polygon. if not hasattr(self,'riversegs'): @@ -1374,15 +1374,15 @@ dist = npy.sqrt(xd+yd) split = dist > 500000. if npy.sum(split) and self.projection not in ['merc','cyl','mill','moll','robin','sinu']: - ind = (npy.compress(split,squeeze(split*npy.indices(xd.shape)))+1).tolist() - xl = [] - yl = [] - iprev = 0 - ind.append(len(xd)) - for i in ind: - xl.append(x[iprev:i]) - yl.append(y[iprev:i]) - iprev = i + ind = (npy.compress(split,squeeze(split*npy.indices(xd.shape)))+1).tolist() + xl = [] + yl = [] + iprev = 0 + ind.append(len(xd)) + for i in ind: + xl.append(x[iprev:i]) + yl.append(y[iprev:i]) + iprev = i else: xl = [x] yl = [y] @@ -1580,15 +1580,15 @@ dist = npy.sqrt(xd+yd) split = dist > 500000. if npy.sum(split) and self.projection not in ['merc','cyl','mill','moll','robin','sinu']: - ind = (npy.compress(split,squeeze(split*npy.indices(xd.shape)))+1).tolist() - xl = [] - yl = [] - iprev = 0 - ind.append(len(xd)) - for i in ind: - xl.append(x[iprev:i]) - yl.append(y[iprev:i]) - iprev = i + ind = (npy.compress(split,squeeze(split*npy.indices(xd.shape)))+1).tolist() + xl = [] + yl = [] + iprev = 0 + ind.append(len(xd)) + for i in ind: + xl.append(x[iprev:i]) + yl.append(y[iprev:i]) + iprev = i else: xl = [x] yl = [y] @@ -2189,7 +2189,7 @@ ax = self.ax else: ax = kwargs.pop('ax') - # make sure x is monotonically increasing - if not, + # make sure x is monotonically increasing - if not, # print warning suggesting that the data be shifted in longitude # with the shiftgrid function. # only do this check for global projections. @@ -2233,7 +2233,7 @@ # reset current active image (only if pylab is imported). try: try: # new contour. - if CS._A is not None: pylab.gci._current = CS + if CS._A is not None: pylab.gci._current = CS except: # old contour. if CS[1].mappable is not None: pylab.gci._current = CS[1].mappable except: @@ -2257,7 +2257,7 @@ ax = self.ax else: ax = kwargs.pop('ax') - # make sure x is monotonically increasing - if not, + # make sure x is monotonically increasing - if not, # print warning suggesting that the data be shifted in longitude # with the shiftgrid function. # only do this check for global projections. @@ -2559,7 +2559,7 @@ if masked: xmask = npy.logical_or(npy.less(xcoords,0),npy.greater(xcoords,len(xin)-1)) ymask = npy.logical_or(npy.less(ycoords,0),npy.greater(ycoords,len(yin)-1)) - xymask = npy.logical_or(xmask,ymask) + xymask = npy.logical_or(xmask,ymask) xcoords = npy.clip(xcoords,0,len(xin)-1) ycoords = npy.clip(ycoords,0,len(yin)-1) # interpolate to output grid using bilinear interpolation. @@ -2657,6 +2657,6 @@ corners = llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat # test for invalid projection points on output if llcrnrlon > 1.e20 or urcrnrlon > 1.e20: - raise ValueError, 'width and/or height too large for this projection, try smaller values' + raise ValueError, 'width and/or height too large for this projection, try smaller values' else: - return corners + return corners This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-19 13:10:52
|
Revision: 4380 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4380&view=rev Author: jswhit Date: 2007-11-19 05:10:49 -0800 (Mon, 19 Nov 2007) Log Message: ----------- more minor reformatting 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 20:54:22 UTC (rev 4379) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-19 13:10:49 UTC (rev 4380) @@ -1,10 +1,10 @@ from matplotlib import rcParams -from matplotlib import __version__ as matplotlib_version +from matplotlib import __version__ as _matplotlib_version # check to make sure matplotlib is not too old. -mpl_required_version = '0.90' -if matplotlib_version < mpl_required_version: +_mpl_required_version = '0.90' +if _matplotlib_version < _mpl_required_version: raise ImportError('your matplotlib is too old - basemap ' - 'requires at least %s, you have %s'%(mpl_required_version,matplotlib_version)) + 'requires version %s or higher'% _matplotlib_version) from matplotlib.collections import LineCollection from matplotlib.patches import Ellipse, Circle, Polygon from matplotlib.lines import Line2D @@ -49,8 +49,8 @@ 'gnom' : 'Gnomonic', } supported_projections = [] -for k,v in _projnames.iteritems(): - supported_projections.append("'%s' = %s\n" % (k,v)) +for _items in _projnames.iteritems(): + supported_projections.append("'%s' = %s\n" % (_items)) supported_projections = ''.join(supported_projections) # The __init__ docstring is pulled out here because it is so long; @@ -61,8 +61,8 @@ arguments: - projection - map projection. Supported projections are:\n"""+\ -supported_projections+""" + projection - map projection. Supported projections are: +%(supported_projections)s Default is 'cyl'. The map projection region can either be specified by setting these keywords: @@ -94,7 +94,7 @@ '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% + Resolution drops off by roughly 80%% between datasets. Higher res datasets are much slower to draw. Default 'c'. Coastline data is from the GSHHS (http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html). @@ -161,7 +161,7 @@ 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'). -""" +""" % locals() # unsupported projection error message. _unsupported_projection = ["'%s' is an unsupported projection.\n"] @@ -191,7 +191,7 @@ Useful instance variables: projection - map projection. Print the module variable - "supported_projections" to see a list of supported projections. + "supported_projections" to see a list. 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. @@ -245,7 +245,7 @@ boundinglat=None, anchor='C', ax=None): - # docstring is added after definition + # docstring is added after __init__ method definition # where to put plot in figure (default is 'C' or center) self.anchor = anchor @@ -281,7 +281,7 @@ _insert_validated(projparams, lon_2, 'lon_2', -360, 720) if satellite_height is not None: projparams['h'] = satellite_height - + # check for sane values of projection corners. using_corners = (None not in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]) if using_corners: self.llcrnrlon = _validated_ll(llcrnrlon, 'llcrnrlon', -360, 720) @@ -292,6 +292,7 @@ # for each of the supported projections, # compute lat/lon of domain corners # and set values in projparams dict as needed. + if projection in ['lcc', 'eqdc', 'aea']: # if lat_0 is given, but not lat_1, # set lat_1=lat_0 @@ -310,9 +311,6 @@ llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat - - # skipping over the following for now; it can be beautified and - # consolidated later 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)' @@ -386,7 +384,6 @@ llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat - elif projection == 'ortho': if not projparams.has_key('R'): raise ValueError, 'orthographic projection only works for perfect spheres - not ellipsoids' @@ -583,6 +580,7 @@ else: coastsegs.append(seg) self.coastsegs = coastsegs + # set __init__'s docstring __init__.__doc__ = _Basemap_init_doc def __call__(self,x,y,inverse=False): @@ -648,7 +646,6 @@ if containsPole and\ self.projection in ['tmerc','cass','omerc','merc','mill','cyl','robin','moll','sinu','geos']: raise ValueError('%s projection cannot cross pole'%(self.projection)) - # make sure orthographic projection has containsPole=True # we will compute the intersections in stereographic # coordinates, then transform to orthographic. @@ -2141,9 +2138,6 @@ """ Make a pseudo-color plot over the map. see pylab.pcolormesh documentation for definition of **kwargs - Unlike pcolor, pcolormesh cannot handle masked arrays, and so - cannot be used to plot data when the grid lies partially outside - the projection limb (use pcolor or contourf instead). extra keyword 'ax' can be used to override the default axis instance. """ if not kwargs.has_key('ax') and self.ax is None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-11-18 20:54:27
|
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<Py::Object> offsets; Transformation* transOffset = NULL; bool usingOffsets = args[7].ptr() != Py_None; @@ -1079,19 +1080,12 @@ std::pair<double, double> 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<Py::Object> pos = Py::SeqBase<Py::Object>(offsets[k]); - xOffsets[k] = Py::Float(pos[0]); - yOffsets[k] = Py::Float(pos[1]); - } + { + Py::SeqBase<Py::Object> pos = Py::SeqBase<Py::Object>(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. |
From: <js...@us...> - 2007-11-18 19:28:36
|
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. |
From: <ef...@us...> - 2007-11-18 19:06:54
|
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() : mcolors.Normalize instance + is used to scale luminance data to 0,1. + + * vmin=None and vmax=None : vmin and vmax are used in conjunction + with norm to normalize luminance data. If either are None, the + min and max of the color array C is used. If you pass a norm + instance, vmin and vmax will be None + + * alpha=1.0 : the alpha blending value + + Return value is an image if a regular or rectangular grid + is specified, and a QuadMesh collection in the general + quadrilateral case. + + """ + + if not self._hold: self.cla() + + alpha = kwargs.pop('alpha', 1.0) + norm = kwargs.pop('norm', None) + cmap = kwargs.pop('cmap', None) + vmin = kwargs.pop('vmin', None) + vmax = kwargs.pop('vmax', None) + if norm is not None: assert(isinstance(norm, mcolors.Normalize)) + if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) + + C = args[-1] + nr, nc = C.shape + if len(args) == 1: + style = "image" + x = [0, nc+1] + y = [0, nr+1] + elif len(args) == 3: + x, y = args[:2] + x = npy.asarray(x) + y = npy.asarray(y) + if x.ndim == 1 and y.ndim == 1: + if x.size == 2 and y.size == 2: + style = "image" + else: + dx = npy.diff(x) + dy = npy.diff(y) + if (npy.ptp(dx) < 0.01*npy.abs(dx.mean()) and + npy.ptp(dy) < 0.01*npy.abs(dy.mean())): + style = "image" + style = "pcolorimage" + elif x.ndim == 2 and y.ndim == 2: + style = "quadmesh" + else: + raise TypeError("arguments do not match valid signatures") + else: + raise TypeError("need 1 argument or 3 arguments") + + if style == "quadmesh": + + # convert to one dimensional arrays + # This should also be moved to the QuadMesh class + C = ma.ravel(C) # data point in each cell is value at lower left corner + X = x.ravel() + Y = y.ravel() + Nx = nc+1 + Ny = nr+1 + + # The following needs to be cleaned up; the renderer + # requires separate contiguous arrays for X and Y, + # but the QuadMesh class requires the 2D array. + coords = npy.empty(((Nx * Ny), 2), npy.float64) + coords[:, 0] = X + coords[:, 1] = Y + + # The QuadMesh class can also be changed to + # handle relevant superclass kwargs; the initializer + # should do much more than it does now. + collection = mcoll.QuadMesh(nc, nr, coords, 0) + collection.set_alpha(alpha) + collection.set_array(C) + collection.set_cmap(cmap) + collection.set_norm(norm) + self.add_collection(collection) + xl, xr, yb, yt = X.min(), X.max(), Y.min(), Y.max() + ret = collection + + else: + # One of the image styles: + xl, xr, yb, yt = x[0], x[-1], y[0], y[-1] + if style == "image": + + im = mimage.AxesImage(self, cmap, norm, + interpolation='nearest', + origin='lower', + extent=(xl, xr, yb, yt), + **kwargs) + im.set_data(C) + im.set_alpha(alpha) + self.images.append(im) + ret = im + + if style == "pcolorimage": + im = mimage.PcolorImage(self, x, y, C, + cmap=cmap, + norm=norm, + alpha=alpha, + **kwargs) + self.images.append(im) + ret = im + + self._set_artist_props(ret) + if vmin is not None or vmax is not None: + ret.set_clim(vmin, vmax) + else: + ret.autoscale_None() + self.update_datalim(npy.array([[xl, yb], [xr, yt]])) + self.autoscale_view(tight=True) + return ret + + + + def contour(self, *args, **kwargs): kwargs['filled'] = False return mcontour.ContourSet(self, *args, **kwargs) @@ -4822,14 +4993,14 @@ ticks on bottom and the returned axes will have ticks on the top """ - + ax2 = self.figure.add_axes(self.get_position(), sharey=self, frameon=False) ax2.xaxis.tick_top() ax2.xaxis.set_label_position('top') self.xaxis.tick_bottom() return ax2 - + #### Data analysis Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2007-11-18 19:02:55 UTC (rev 4376) +++ trunk/matplotlib/lib/matplotlib/image.py 2007-11-18 19:06:49 UTC (rev 4377) @@ -410,9 +410,107 @@ raise RuntimeError('Cannot change colors after loading data') cm.ScalarMappable.set_cmap(self, norm) +class PcolorImage(martist.Artist, cm.ScalarMappable): + def __init__(self, ax, + x=None, + y=None, + A=None, + cmap = None, + norm = None, + **kwargs + ): + """ + cmap defaults to its rc setting + cmap is a colors.Colormap instance + norm is a colors.Normalize instance to map luminance to 0-1 + Additional kwargs are matplotlib.artist properties + """ + martist.Artist.__init__(self) + cm.ScalarMappable.__init__(self, norm, cmap) + self.axes = ax + self._rgbacache = None + self.update(kwargs) + self.set_data(x, y, A) + + def make_image(self, magnification=1.0): + if self._A is None: + raise RuntimeError('You must first set the image array') + fc = self.axes.get_frame().get_facecolor() + bg = mcolors.colorConverter.to_rgba(fc, 0) + bg = (npy.array(bg)*255).astype(npy.uint8) + x0, y0, v_width, v_height = self.axes.viewLim.get_bounds() + l, b, width, height = self.axes.bbox.get_bounds() + width *= magnification + height *= magnification + if self.check_update('array'): + A = self.to_rgba(self._A, alpha=self._alpha, bytes=True) + self._rgbacache = A + if self._A.ndim == 2: + self.is_grayscale = self.cmap.is_gray() + else: + A = self._rgbacache + im = _image.pcolor2(self._Ax, self._Ay, A, + height, width, + (x0, x0+v_width, y0, y0+v_height), + bg) + im.is_grayscale = self.is_grayscale + return im + + def draw(self, renderer, *args, **kwargs): + if not self.get_visible(): return + im = self.make_image(renderer.get_image_magnification()) + l, b, widthDisplay, heightDisplay = self.axes.bbox.get_bounds() + renderer.draw_image(l, b, im, self.axes.bbox) + + + def set_data(self, x, y, A): + A = ma.asarray(A) + if x is None: + x = npy.arange(0, A.shape[1]+1, dtype=npy.float64) + else: + x = npy.asarray(x, npy.float64).ravel() + if y is None: + y = npy.arange(0, A.shape[0]+1, dtype=npy.float64) + else: + y = npy.asarray(y, npy.float64).ravel() + + if A.shape[:2] != (y.size-1, x.size-1): + print A.shape + print y.size + print x.size + raise ValueError("Axes don't match array shape") + if A.ndim not in [2, 3]: + raise ValueError("A must be 2D or 3D") + if A.ndim == 3 and A.shape[2] == 1: + A.shape = A.shape[:2] + self.is_grayscale = False + if A.ndim == 3: + if A.shape[2] in [3, 4]: + if (A[:,:,0] == A[:,:,1]).all() and (A[:,:,0] == A[:,:,2]).all(): + self.is_grayscale = True + else: + raise ValueError("3D arrays must have RGB or RGBA as last dim") + self._A = A + self._Ax = x + self._Ay = y + self.update_dict['array'] = True + + def set_array(self, *args): + raise NotImplementedError('Method not supported') + + def set_alpha(self, alpha): + """ + Set the alpha value used for blending - not supported on + all backends + + ACCEPTS: float + """ + martist.Artist.set_alpha(self, alpha) + self.update_dict['array'] = True + class FigureImage(martist.Artist, cm.ScalarMappable): def __init__(self, fig, cmap = None, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-11-18 19:02:56
|
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. |
From: <ef...@us...> - 2007-11-18 19:01:41
|
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<Py::Object> 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<Ndash; i++) { @@ -163,24 +163,24 @@ void GCAgg::_set_clip_rectangle( const Py::Object& gc) { //set the clip rectangle from the gc - + _VERBOSE("GCAgg::_set_clip_rectangle"); - + delete [] cliprect; cliprect = NULL; - + Py::Object o ( gc.getAttr( "_cliprect" ) ); if (o.ptr()==Py_None) { return; } - + Py::SeqBase<Py::Object> 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); scanlineAlphaMask = new agg::scanline_p8(); - - + + slineP8 = new scanline_p8; slineBin = new scanline_bin; - - + + pixFmt = new pixfmt(*renderingBuffer); rendererBase = new renderer_base(*pixFmt); rendererBase->clear(agg::rgba(1, 1, 1, 0)); - + rendererAA = new renderer_aa(*rendererBase); rendererBin = new renderer_bin(*rendererBase); theRasterizer = new rasterizer(); //theRasterizer->filling_rule(agg::fill_even_odd); //theRasterizer->filling_rule(agg::fill_non_zero); - + }; @@ -279,10 +279,10 @@ void RendererAgg::set_clipbox_rasterizer( double *cliprect) { //set the clip rectangle from the gc - + _VERBOSE("RendererAgg::set_clipbox_rasterizer"); - + theRasterizer->reset_clipping(); rendererBase->reset_clipping(true); @@ -291,24 +291,24 @@ // rendererBase->reset_clipping(true); //} if (cliprect!=NULL) { - + double l = cliprect[0] ; double b = cliprect[1] ; double w = cliprect[2] ; double h = cliprect[3] ; - + theRasterizer->clip_box(l, height-(b+h), l+w, height-b); } _VERBOSE("RendererAgg::set_clipbox_rasterizer done"); - + } std::pair<bool, agg::rgba> RendererAgg::_get_rgba_face(const Py::Object& rgbFace, double alpha) { _VERBOSE("RendererAgg::_get_rgba_face"); std::pair<bool, agg::rgba> face; - + if (rgbFace.ptr() == Py_None) { face.first = false; } @@ -318,7 +318,7 @@ face.second = rgb_to_color(rgb, alpha); } return face; - + } template <class VS> @@ -328,9 +328,9 @@ const facepair_t& face, bool curvy) { typedef agg::conv_curve<VS> curve_t; - + //bool isclippath(gc.clippath!=NULL); - //if (isclippath) _process_alpha_mask(gc); + //if (isclippath) _process_alpha_mask(gc); if (face.first) { rendererAA->color(face.second); @@ -340,7 +340,7 @@ } else theRasterizer->add_path(path); - + /* if (isclippath) { typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; @@ -351,7 +351,7 @@ renderer_type ren(r); ren.color(gc.color); //std::cout << "render clippath" << std::endl; - + agg::render_scanlines(*theRasterizer, *slineP8, ren); } else { @@ -361,7 +361,7 @@ */ agg::render_scanlines(*theRasterizer, *slineP8, *rendererAA); } - + //now stroke the edge if (gc.linewidth) { if (curvy) { @@ -379,8 +379,8 @@ stroke.line_join(gc.join); theRasterizer->add_path(stroke); } - - + + /* if ( gc.isaa ) { if (isclippath) { @@ -392,7 +392,7 @@ renderer_type ren(r); ren.color(gc.color); //std::cout << "render clippath" << std::endl; - + agg::render_scanlines(*theRasterizer, *slineP8, ren); } else { @@ -418,7 +418,7 @@ } */ - + if ( gc.isaa ) { rendererAA->color(gc.color); agg::render_scanlines(*theRasterizer, *slineP8, *rendererAA); @@ -428,71 +428,71 @@ agg::render_scanlines(*theRasterizer, *slineBin, *rendererBin); } } - + } Py::Object RendererAgg::draw_rectangle(const Py::Tuple & args) { _VERBOSE("RendererAgg::draw_rectangle"); args.verify_length(6); - - + + GCAgg gc = GCAgg(args[0], dpi); facepair_t face = _get_rgba_face(args[1], gc.alpha); - - + + double l = Py::Float( args[2] ); double b = Py::Float( args[3] ); double w = Py::Float( args[4] ); double h = Py::Float( args[5] ); - + b = height - (b+h); double r = l + w; double t = b + h; - + //snapto pixel centers l = (int)l + 0.5; b = (int)b + 0.5; r = (int)r + 0.5; t = (int)t + 0.5; - - + + set_clipbox_rasterizer(gc.cliprect); - + agg::path_storage path; - - + + path.move_to(l, t); path.line_to(r, t); path.line_to(r, b); path.line_to(l, b); path.close_polygon(); - + _fill_and_stroke(path, gc, face, false); - + return Py::Object(); - + } Py::Object RendererAgg::draw_ellipse(const Py::Tuple& args) { _VERBOSE("RendererAgg::draw_ellipse"); args.verify_length(7); - + GCAgg gc = GCAgg(args[0], dpi); facepair_t face = _get_rgba_face(args[1], gc.alpha); - + double x = Py::Float( args[2] ); double y = Py::Float( args[3] ); double w = Py::Float( args[4] ); double h = Py::Float( args[5] ); double rot = Py::Float( args[6] ); - + double r; // rot in radians - + set_clipbox_rasterizer(gc.cliprect); - + // Approximate the ellipse with 4 bezier paths agg::path_storage path; if (rot == 0.0) // simple case @@ -515,35 +515,35 @@ path.arc_to(w, h, -r, false, true, x+(cos(r)*w), height-(y+(sin(r)*w))); path.close_polygon(); } - + _fill_and_stroke(path, gc, face); return Py::Object(); - + } Py::Object RendererAgg::draw_polygon(const Py::Tuple& args) { _VERBOSE("RendererAgg::draw_polygon"); - + args.verify_length(3); - + GCAgg gc = GCAgg(args[0], dpi); facepair_t face = _get_rgba_face(args[1], gc.alpha); - + Py::SeqBase<Py::Object> points( args[2] ); - + set_clipbox_rasterizer(gc.cliprect); - + size_t Npoints = points.length(); if (Npoints<=0) return Py::Object(); - - + + // dump the x.y vertices into a double array for faster look ahead // and behind access double *xs = new double[Npoints]; double *ys = new double[Npoints]; - + for (size_t i=0; i<Npoints; i++) { Py::SeqBase<Py::Object> xy(points[i]); xy = Py::Tuple(points[i]); @@ -551,32 +551,32 @@ ys[i] = Py::Float(xy[1]); ys[i] = height - ys[i]; } - - - + + + agg::path_storage path; for (size_t j=0; j<Npoints; j++) { - + double x = xs[j]; double y = ys[j]; - + //snapto pixel centers x = (int)x + 0.5; y = (int)y + 0.5; - + if (j==0) path.move_to(x,y); else path.line_to(x,y); } path.close_polygon(); - + _fill_and_stroke(path, gc, face, false); - + delete [] xs; delete [] ys; - + _VERBOSE("RendererAgg::draw_polygon DONE"); return Py::Object(); - + } @@ -587,7 +587,7 @@ ysnap = (int)y + 0.5; - + if ( first || ( (xsnap!=lastxsnap) || (ysnap!=lastysnap) ) ) { lastxsnap = xsnap; lastysnap = ysnap; @@ -604,7 +604,7 @@ lastysnap = ysnap; lastx = x; lasty = y; - return SnapData(false, xsnap, ysnap); + return SnapData(false, xsnap, ysnap); } // ok the real points are not identical but the rounded ones, so do @@ -619,34 +619,34 @@ lastysnap = ysnap; lastx = x; lasty = y; - return SnapData(true, xsnap, ysnap); -} - - - + return SnapData(true, xsnap, ysnap); +} + + + Py::Object RendererAgg::draw_line_collection(const Py::Tuple& args) { - + _VERBOSE("RendererAgg::draw_line_collection"); - + args.verify_length(9); theRasterizer->reset_clipping(); - - + + //segments, trans, clipbox, colors, linewidths, antialiaseds Py::SeqBase<Py::Object> segments = args[0]; - + Transformation* transform = static_cast<Transformation*>(args[1].ptr()); - + set_clip_from_bbox(args[2]); - + Py::SeqBase<Py::Object> colors = args[3]; Py::SeqBase<Py::Object> linewidths = args[4]; Py::SeqBase<Py::Object> linestyle = args[5]; Py::SeqBase<Py::Object> antialiaseds = args[6]; - + bool usingOffsets = args[7].ptr()!=Py_None; Py::SeqBase<Py::Object> offsets; Transformation* transOffset=NULL; @@ -654,7 +654,7 @@ offsets = Py::SeqBase<Py::Object>(args[7]); transOffset = static_cast<Transformation*>(args[8].ptr()); } - + size_t Nsegments = segments.length(); size_t Nc = colors.length(); size_t Nlw = linewidths.length(); @@ -662,37 +662,37 @@ size_t Noffsets = 0; size_t N = Nsegments; size_t Ndash = 0; - + Py::SeqBase<Py::Object> dashtup(linestyle); bool useDashes = dashtup[0].ptr() != Py_None; - + double offset = 0; Py::SeqBase<Py::Object> dashSeq; typedef agg::conv_dash<agg::path_storage> dash_t; double *dasha = NULL; - + if ( useDashes ) { - + //TODO: use offset offset = points_to_pixels_snapto(dashtup[0]); dashSeq = dashtup[1]; - + Ndash = dashSeq.length(); if (Ndash%2 != 0 ) throw Py::ValueError(Printf("dashes must be an even length sequence; found %d", N).str()); - + dasha = new double[Ndash]; - + for (size_t i=0; i<Ndash; i++) dasha[i] = points_to_pixels(dashSeq[i]); } - - + + if (usingOffsets) { Noffsets = offsets.length(); if (Noffsets>Nsegments) N = Noffsets; } - + double xo(0.0), yo(0.0), thisx(0.0), thisy(0.0); std::pair<double, double> xy; Py::SeqBase<Py::Object> xyo; @@ -708,24 +708,24 @@ catch (...) { throw Py::ValueError("Domain error on transOffset->operator in draw_line_collection"); } - + xo = xy.first; yo = xy.second; } - + xys = segments[i%Nsegments]; size_t numtups = xys.length(); if (numtups<2) continue; - + bool snapto=numtups==2; agg::path_storage path; //std::cout << "trying snapto " << numtups << " " << snapto << std::endl; SafeSnap snap; - - + + for (size_t j=0; j<numtups; j++) { xyo = xys[j]; thisx = Py::Float(xyo[0]); @@ -733,19 +733,19 @@ try { xy = transform->operator()(thisx,thisy); } - + catch (...) { throw Py::ValueError("Domain error on transOffset->operator in draw_line_collection"); } - + thisx = xy.first; thisy = xy.second; - + if (usingOffsets) { thisx += xo; thisy += yo; } - + if (snapto) { // snap to pixel for len(2) lines SnapData snapdata(snap.snap(thisx, thisy)); // TODO: process newpoint @@ -759,17 +759,17 @@ //thisx = (int)thisx + 0.5; //thisy = (int)thisy + 0.5; } - + if (j==0) path.move_to(thisx, height-thisy); else path.line_to(thisx, height-thisy); } - - - + + + double lw = points_to_pixels ( Py::Float( linewidths[i%Nlw] ) ); - + if (! useDashes ) { - + agg::conv_stroke<agg::path_storage> stroke(path); //stroke.line_cap(cap); //stroke.line_join(join); @@ -777,19 +777,19 @@ theRasterizer->add_path(stroke); } else { - + dash_t dash(path); //dash.dash_start(offset); for (size_t idash=0; idash<Ndash/2; idash++) dash.add_dash(dasha[2*idash], dasha[2*idash+1]); - + agg::conv_stroke<dash_t> stroke(dash); //stroke.line_cap(cap); //stroke.line_join(join); stroke.width(lw); theRasterizer->add_path(stroke); } - + // get the color and render Py::SeqBase<Py::Object> rgba(colors[ i%Nc]); double r = Py::Float(rgba[0]); @@ -797,7 +797,7 @@ double b = Py::Float(rgba[2]); double a = Py::Float(rgba[3]); agg::rgba color(r, g, b, a); - + // render antialiased or not int isaa = Py::Int(antialiaseds[i%Naa]); if ( isaa ) { @@ -819,8 +819,8 @@ RendererAgg::copy_from_bbox(const Py::Tuple& args) { //copy region in bbox to buffer and return swig/agg buffer object args.verify_length(1); - - + + agg::rect r = bbox_to_rect(args[0]); /* r.x1 -=5; @@ -835,19 +835,19 @@ if (buf.data ==NULL) { throw Py::MemoryError("RendererAgg::copy_from_bbox could not allocate memory for buffer"); } - + agg::rendering_buffer rbuf; rbuf.attach(buf.data, boxwidth, boxheight, boxstride); - + pixfmt pf(rbuf); renderer_base rb(pf); //rb.clear(agg::rgba(1, 0, 0)); //todo remove me rb.copy_from(*renderingBuffer, &r, -r.x1, -r.y1); BufferRegion* reg = new BufferRegion(buf, r, true); return Py::asObject(reg); - - - + + + } Py::Object @@ -855,57 +855,57 @@ //copy BufferRegion to buffer args.verify_length(1); BufferRegion* region = static_cast<BufferRegion*>(args[0].ptr()); - + if (region->aggbuf.data==NULL) return Py::Object(); //throw Py::ValueError("Cannot restore_region from NULL data"); - - + + agg::rendering_buffer rbuf; rbuf.attach(region->aggbuf.data, region->aggbuf.width, region->aggbuf.height, region->aggbuf.stride); - + rendererBase->copy_from(rbuf, 0, region->rect.x1, region->rect.y1); - + return Py::Object(); - - - + + + } agg::rect_base<int> RendererAgg::bbox_to_rect(const Py::Object& o) { //return the agg::rect for bbox, flipping y - + Bbox* clipbox = static_cast<Bbox*>(o.ptr()); double l = clipbox->ll_api()->x_api()->val() ; double b = clipbox->ll_api()->y_api()->val(); double r = clipbox->ur_api()->x_api()->val() ; double t = clipbox->ur_api()->y_api()->val() ; ; - + agg::rect rect( (int)l, height-(int)t, (int)r, height-(int)b ) ; if (!rect.is_valid()) throw Py::ValueError("Invalid rectangle in bbox_to_rect"); return rect; - + } void RendererAgg::set_clip_from_bbox(const Py::Object& o) { - + // do not puut this in the else below. We want to unconditionally // clear the clip theRasterizer->reset_clipping(); rendererBase->reset_clipping(true); - + if (o.ptr() != Py_None) { //using clip // Bbox::check(args[0]) failing; something about cross module? // set the clip rectangle // flipy - + Bbox* clipbox = static_cast<Bbox*>(o.ptr()); double l = clipbox->ll_api()->x_api()->val() ; double b = clipbox->ll_api()->y_api()->val(); @@ -914,7 +914,7 @@ theRasterizer->clip_box(l, height-t, r, height-b); rendererBase->clip_box((int)l, (int)(height-t), (int)r, (int)(height-b)); } - + } /****************************/ @@ -940,7 +940,7 @@ double ycoord = (double(row) + 0.5); for(i=0; i<=3; i++) numIntersect += intersectCheck(ycoord, xs[i], ys[i], xs[(i+1)%4], ys[(i+1)%4], col+numIntersect); - + /* reorder if necessary */ if (numIntersect == 2 && col[0] > col[1]) std::swap(col[0],col[1]); if (numIntersect == 4) { @@ -1027,7 +1027,7 @@ Py::Object RendererAgg::draw_quad_mesh(const Py::Tuple& args){ - + //printf("#1: %d\n", clock()); Py::Object colorsi = args[2]; Py::Object xCoordsi = args[3]; @@ -1043,16 +1043,16 @@ /* do transformations */ //todo: fix transformation check Transformation* transform = static_cast<Transformation*>(args[6].ptr()); - + try { transform->eval_scalars(); } catch(...) { throw Py::ValueError("Domain error on eval_scalars in RendererAgg::draw_quad_mesh"); } - + set_clip_from_bbox(args[5]); - + Py::SeqBase<Py::Object> offsets; Transformation* transOffset = NULL; bool usingOffsets = args[7].ptr() != Py_None; @@ -1066,7 +1066,7 @@ catch(...) { throw Py::ValueError("Domain error on transOffset eval_scalars in RendererAgg::draw_quad_mesh"); } - + } size_t Noffsets; if(usingOffsets) @@ -1075,9 +1075,9 @@ Noffsets = 0; size_t Nverts = xCoords->dimensions[0]; /* size_t N = (Noffsets>Nverts) ? Noffsets : Nverts; */ - + std::pair<double, double> xyo, xy; - + //do non-offset transformations double* xCoordsa = new double[Nverts]; double* yCoordsa = new double[Nverts]; @@ -1115,14 +1115,14 @@ delete newXOffsets; delete newYOffsets; } - + for(q=0; q < Nverts; q++) { newYCoords[q] = height - newYCoords[q]; } - + /**** End of transformations ****/ - + /* convert colors */ double r; double g; @@ -1155,33 +1155,33 @@ Py::Object RendererAgg::draw_poly_collection(const Py::Tuple& args) { theRasterizer->reset_clipping(); - + _VERBOSE("RendererAgg::draw_poly_collection"); - + args.verify_length(9); - - + + Py::SeqBase<Py::Object> verts = args[0]; - + //todo: fix transformation check Transformation* transform = static_cast<Transformation*>(args[1].ptr()); - + try { transform->eval_scalars(); } catch(...) { throw Py::ValueError("Domain error on eval_scalars in RendererAgg::draw_poly_collection"); } - - + + set_clip_from_bbox(args[2]); - + Py::SeqBase<Py::Object> facecolors = args[3]; Py::SeqBase<Py::Object> edgecolors = args[4]; Py::SeqBase<Py::Object> linewidths = args[5]; Py::SeqBase<Py::Object> antialiaseds = args[6]; - - + + Py::SeqBase<Py::Object> offsets; Transformation* transOffset = NULL; bool usingOffsets = args[7].ptr() != Py_None; @@ -1195,25 +1195,25 @@ catch(...) { throw Py::ValueError("Domain error on transoffset eval_scalars in RendererAgg::draw_poly_collection"); } - + } - + size_t Noffsets = offsets.length(); size_t Nverts = verts.length(); size_t Nface = facecolors.length(); size_t Nedge = edgecolors.length(); size_t Nlw = linewidths.length(); size_t Naa = antialiaseds.length(); - + size_t N = (Noffsets>Nverts) ? Noffsets : Nverts; - + std::pair<double, double> xyo, xy; Py::SeqBase<Py::Object> thisverts; size_t i, j; for (i=0; i<N; i++) { - + thisverts = verts[i % Nverts]; - + if (usingOffsets) { Py::SeqBase<Py::Object> pos = Py::SeqBase<Py::Object>(offsets[i]); double xo = Py::Float(pos[0]); @@ -1224,15 +1224,15 @@ catch (...) { throw Py::ValueError("Domain error on transOffset->operator in draw_line_collection"); } - + } - + size_t Nverts = thisverts.length(); agg::path_storage path; - + Py::SeqBase<Py::Object> thisvert; - - + + // dump the verts to double arrays so we can do more efficient // look aheads and behinds when doing snapto pixels double *xs = new double[Nverts]; @@ -1249,24 +1249,24 @@ delete [] ys; throw Py::ValueError("Domain error on eval_scalars in RendererAgg::draw_poly_collection"); } - - + + if (usingOffsets) { xy.first += xyo.first; xy.second += xyo.second; } - + xy.second = height - xy.second; xs[j] = xy.first; ys[j] = xy.second; - + } - + for (j=0; j<Nverts; j++) { - + double x = xs[j]; double y = ys[j]; - + if (j==0) { if (xs[j] == xs[Nverts-1]) x = (int)xs[j] + 0.5; if (ys[j] == ys[Nverts-1]) y = (int)ys[j] + 0.5; @@ -1275,7 +1275,7 @@ if (xs[j] == xs[0]) x = (int)xs[j] + 0.5; if (ys[j] == ys[0]) y = (int)ys[j] + 0.5; } - + if (j < Nverts-1) { if (xs[j] == xs[j+1]) x = (int)xs[j] + 0.5; if (ys[j] == ys[j+1]) y = (int)ys[j] + 0.5; @@ -1284,11 +1284,11 @@ if (xs[j] == xs[j-1]) x = (int)xs[j] + 0.5; if (ys[j] == ys[j-1]) y = (int)ys[j] + 0.5; } - + if (j==0) path.move_to(x,y); else path.line_to(x,y); } - + path.close_polygon(); int isaa = Py::Int(antialiaseds[i%Naa]); // get the facecolor and render @@ -1299,9 +1299,9 @@ double a = Py::Float(rgba[3]); if (a>0) { //only render if alpha>0 agg::rgba facecolor(r, g, b, a); - + theRasterizer->add_path(path); - + if (isaa) { rendererAA->color(facecolor); agg::render_scanlines(*theRasterizer, *slineP8, *rendererAA); @@ -1311,24 +1311,24 @@ agg::render_scanlines(*theRasterizer, *slineBin, *rendererBin); } } //renderer face - + // get the edgecolor and render rgba = Py::SeqBase<Py::Object>(edgecolors[ i%Nedge]); r = Py::Float(rgba[0]); g = Py::Float(rgba[1]); b = Py::Float(rgba[2]); a = Py::Float(rgba[3]); - + double lw = points_to_pixels ( Py::Float( linewidths[i%Nlw] ) ); if ((a>0) && lw) { //only render if alpha>0 and linewidth !=0 agg::rgba edgecolor(r, g, b, a); - + agg::conv_stroke<agg::path_storage> stroke(path); //stroke.line_cap(cap); //stroke.line_join(join); stroke.width(lw); theRasterizer->add_path(stroke); - + // render antialiased or not if ( isaa ) { rendererAA->color(edgecolor); @@ -1339,10 +1339,10 @@ agg::render_scanlines(*theRasterizer, *slineBin, *rendererBin); } } //rendered edge - + delete [] xs; delete [] ys; - + } // for every poly return Py::Object(); } @@ -1350,37 +1350,37 @@ Py::Object RendererAgg::draw_regpoly_collection(const Py::Tuple& args) { theRasterizer->reset_clipping(); - + _VERBOSE("RendererAgg::draw_regpoly_collection"); args.verify_length(9); - - + + set_clip_from_bbox(args[0]); - + Py::SeqBase<Py::Object> offsets = args[1]; - + // this is throwing even though the instance is a Transformation! //if (!Transformation::check(args[2])) // throw Py::TypeError("RendererAgg::draw_regpoly_collection(clipbox, offsets, transOffset, verts, ...) expected a Transformation instance for transOffset"); - + Transformation* transOffset = static_cast<Transformation*>(args[2].ptr()); - - + + try { transOffset->eval_scalars(); } catch(...) { throw Py::ValueError("Domain error on eval_scalars in RendererAgg::draw_regpoly_collection"); } - - + + Py::SeqBase<Py::Object> verts = args[3]; Py::SeqBase<Py::Object> sizes = args[4]; Py::SeqBase<Py::Object> facecolors = args[5]; Py::SeqBase<Py::Object> edgecolors = args[6]; Py::SeqBase<Py::Object> linewidths = args[7]; Py::SeqBase<Py::Object> antialiaseds = args[8]; - + size_t Noffsets = offsets.length(); size_t Nverts = verts.length(); size_t Nsizes = sizes.length(); @@ -1388,9 +1388,9 @@ size_t Nedge = edgecolors.length(); size_t Nlw = linewidths.length(); size_t Naa = antialiaseds.length(); - + double thisx, thisy; - + // dump the x.y vertices into a double array for faster access double *xverts = new double[Nverts]; double *yverts = new double[Nverts]; @@ -1401,7 +1401,7 @@ xverts[i] = Py::Float(xy[0]); yverts[i] = Py::Float(xy[1]); } - + std::pair<double, double> offsetPair; for (i=0; i<Noffsets; i++) { Py::SeqBase<Py::Object> pos = Py::SeqBase<Py::Object>(offsets[i]); @@ -1415,22 +1415,22 @@ delete [] yverts; throw Py::ValueError("Domain error on eval_scalars in RendererAgg::draw_regpoly_collection"); } - - - + + + double scale = Py::Float(sizes[i%Nsizes]); - - + + agg::path_storage path; - + for (j=0; j<Nverts; j++) { thisx = scale*xverts[j] + offsetPair.first; thisy = scale*yverts[j] + offsetPair.second; thisy = height - thisy; if (j==0) path.move_to(thisx, thisy); else path.line_to(thisx, thisy); - - + + } path.close_polygon(); int isaa = Py::Int(antialiaseds[i%Naa]); @@ -1442,9 +1442,9 @@ double a = Py::Float(rgba[3]); if (a>0) { //only render if alpha>0 agg::rgba facecolor(r, g, b, a); - + theRasterizer->add_path(path); - + if (isaa) { rendererAA->color(facecolor); agg::render_scanlines(*theRasterizer, *slineP8, *rendererAA); @@ -1454,7 +1454,7 @@ agg::render_scanlines(*theRasterizer, *slineBin, *rendererBin); } } //renderer face - + // get the edgecolor and render rgba = Py::SeqBase<Py::Object>(edgecolors[ i%Nedge]); r = Py::Float(rgba[0]); @@ -1464,13 +1464,13 @@ double lw = points_to_pixels ( Py::Float( linewidths[i%Nlw] ) ); if ((a>0) && lw) { //only render if alpha>0 agg::rgba edgecolor(r, g, b, a); - + agg::conv_stroke<agg::path_storage> stroke(path); //stroke.line_cap(cap); //stroke.line_join(join); stroke.width(lw); theRasterizer->add_path(stroke); - + // render antialiased or not if ( isaa ) { rendererAA->color(edgecolor); @@ -1481,7 +1481,7 @@ agg::render_scanlines(*theRasterizer, *slineBin, *rendererBin); } } //rendered edge - + } // for every poly delete [] xverts; delete [] yverts; @@ -1490,7 +1490,7 @@ Py::Object RendererAgg::draw_lines(const Py::Tuple& args) { - + _VERBOSE("RendererAgg::draw_lines"); args.verify_length(4); @@ -1560,20 +1560,20 @@ double lastx(0), lasty(0); double lastWrittenx(0), lastWritteny(0); bool clipped = false; - + bool haveMin = false, lastMax = true; double dnorm2Min(0), dnorm2Max(0); double maxX(0), maxY(0), minX(0), minY(0); - + double totdx, totdy, totdot; double paradx, parady, paradNorm2; double perpdx, perpdy, perpdNorm2; - + int counter = 0; - //idea: we can skip drawing many lines: lines < 1 pixel in length, lines + //idea: we can skip drawing many lines: lines < 1 pixel in length, lines //outside of the drawing area, and we can combine sequential parallel lines //into a single line instead of redrawing lines over the same points. - //The loop below works a bit like a state machine, where what it does depends + //The loop below works a bit like a state machine, where what it does depends //on what it did in the last looping. To test whether sequential lines //are close to parallel, I calculate the distance moved perpendicular to the //last line. Once it gets too big, the lines cannot be combined. @@ -1594,18 +1594,18 @@ moveto = true; continue; } - + //use agg's transformer? xytrans.transform(&thisx, &thisy); thisy = heightd - thisy; //flipy - + if (snapto) { //disable subpixel rendering for horizontal or vertical lines of len=2 //because it causes irregular line widths for grids and ticks thisx = (int)thisx + 0.5; thisy = (int)thisy + 0.5; } - + //if we are starting a new path segment, move to the first point + init if(moveto){ path.move_to(thisx, thisy); @@ -1620,7 +1620,7 @@ if (fabs(thisx-lastx) < 1.0 && fabs(thisy-lasty) < 1.0 ){ continue; //don't update lastx this time! } - + //skip any lines that are outside the drawing area. Note: More lines //could be clipped, but a more involved calculation would be needed if( (thisx < 0 && lastx < 0 ) || @@ -1629,10 +1629,10 @@ (thisy > height && lasty > height) ){ lastx = thisx; lasty = thisy; - clipped = true; + clipped = true; continue; } - + //if we have no orig vector, set it to this vector and continue. //this orig vector is the reference vector we will build up the line to if(origdNorm2 == 0){ @@ -1641,11 +1641,11 @@ path.move_to(lastx, lasty); clipped = false; } - + origdx = thisx - lastx; origdy = thisy - lasty; origdNorm2 = origdx*origdx + origdy*origdy; - + //set all the variables to reflect this new orig vecor dnorm2Max = origdNorm2; dnorm2Min = 0; @@ -1653,52 +1653,52 @@ lastMax = true; maxX = thisx; maxY = thisy; - minX = lastx; - minY = lasty; - + minX = lastx; + minY = lasty; + lastWrittenx = lastx; - lastWritteny = lasty; - + lastWritteny = lasty; + //set the last point seen lastx = thisx; - lasty = thisy; + lasty = thisy; continue; } - - //if got to here, then we have an orig vector and we just got + + //if got to here, then we have an orig vector and we just got //a vector in the sequence. - + //check that the perpendicular distance we have moved from the - //last written point compared to the line we are building is not too - //much. If o is the orig vector (we are building on), and v is the vector - //from the last written point to the current point, then the perpendicular - //vector is p = v - (o.v)o, and we normalize o (by dividing the - //second term by o.o). - + //last written point compared to the line we are building is not too + //much. If o is the orig vector (we are building on), and v is the vector + //from the last written point to the current point, then the perpendicular + //vector is p = v - (o.v)o, and we normalize o (by dividing the + //second term by o.o). + //get the v vector totdx = thisx - lastWrittenx; totdy = thisy - lastWritteny; totdot = origdx*totdx + origdy*totdy; - + //get the para vector ( = (o.v)o/(o.o) ) paradx = totdot*origdx/origdNorm2; parady = totdot*origdy/origdNorm2; paradNorm2 = paradx*paradx + parady*parady; - + //get the perp vector ( = v - para ) perpdx = totdx - paradx; - perpdy = totdy - parady; - perpdNorm2 = perpdx*perpdx + perpdy*perpdy; - + perpdy = totdy - parady; + perpdNorm2 = perpdx*perpdx + perpdy*perpdy; + //if the perp vector is less than some number of (squared) pixels in size, //then merge the current vector if(perpdNorm2 < 0.25 ){ //check if the current vector is parallel or //anti-parallel to the orig vector. If it is parallel, test - //if it is the longest of the vectors we are merging in that direction. - //If anti-p, test if it is the longest in the opposite direction (the + //if it is the longest of the vectors we are merging in that direction. + //If anti-p, test if it is the longest in the opposite direction (the //min of our final line) - + lastMax = false; if(totdot >= 0){ if(paradNorm2 > dnorm2Max){ @@ -1709,7 +1709,7 @@ } } else{ - + haveMin = true; if(paradNorm2 > dnorm2Min){ dnorm2Min = paradNorm2; @@ -1717,60 +1717,60 @@ minY = lastWritteny + parady; } } - + lastx = thisx; lasty = thisy; continue; } - + //if we get here, then this vector was not similar enough to the line //we are building, so we need to draw that line and start the next one. - + //if the line needs to extend in the opposite direction from the direction //we are drawing in, move back to we start drawing from back there. if(haveMin){ path.line_to(minX, minY); //would be move_to if not for artifacts } - + path.line_to(maxX, maxY); - + //if we clipped some segments between this line and the next line //we are starting, we also need to move to the last point. if(clipped){ path.move_to(lastx, lasty); } else if(!lastMax){ - //if the last line was not the longest line, then move back to the end + //if the last line was not the longest line, then move back to the end //point of the last line in the sequence. Only do this if not clipped, //since in that case lastx,lasty is not part of the line just drawn. path.line_to(lastx, lasty); //would be move_to if not for artifacts - } + } //std::cout << "draw lines (" << lastx << ", " << lasty << ")" << std::endl; //now reset all the variables to get ready for the next line - + origdx = thisx - lastx; origdy = thisy - lasty; origdNorm2 = origdx*origdx + origdy*origdy; - + dnorm2Max = origdNorm2; dnorm2Min = 0; haveMin = false; lastMax = true; maxX = thisx; maxY = thisy; - minX = lastx; + minX = lastx; minY = lasty; - + lastWrittenx = lastx; - lastWritteny = lasty; - + lastWritteny = lasty; + clipped = false; - + lastx = thisx; lasty = thisy; - + counter++; } @@ -1778,11 +1778,11 @@ if(origdNorm2 != 0){ if(haveMin){ path.line_to(minX, minY); //would be move_to if not for artifacts - } - + } + path.line_to(maxX, maxY); } - + //std::cout << "drew " << counter+1 << " lines" << std::endl; Py_XDECREF(xa); @@ -1798,7 +1798,7 @@ } -bool +bool RendererAgg::_process_alpha_mask(const GCAgg& gc) //if gc has a clippath set, process the alpha mask and return True, //else return False @@ -1827,9 +1827,9 @@ //typedef agg::conv_transform<agg::path_storage, agg::trans_affine> path_t; typedef agg::conv_stroke<path_t> stroke_t; typedef agg::conv_dash<path_t> dash_t; - + bool isclippath(gc.clippath!=NULL); - + if (gc.dasha==NULL ) { //no dashes stroke_t stroke(path); stroke.width(gc.linewidth); @@ -1839,19 +1839,19 @@ } else { dash_t dash(path); - + //todo: dash.dash_start(gc.dashOffset); for (size_t i=0; i<gc.Ndash/2; i+=1) dash.add_dash(gc.dasha[2*i], gc.dasha[2*i+1]); - + agg::conv_stroke<dash_t> stroke(dash); stroke.line_cap(gc.cap); stroke.line_join(gc.join); stroke.width(gc.linewidth); theRasterizer->add_path(stroke); //boyle freeze is herre } - - + + if ( gc.isaa ) { if (isclippath) { typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; @@ -1862,7 +1862,7 @@ renderer_type ren(r); ren.color(gc.color); //std::cout << "render clippath" << std::endl; - + agg::render_scanlines(*theRasterizer, *slineP8, ren); } else { @@ -1891,39 +1891,39 @@ Py::Object RendererAgg::draw_markers(const Py::Tuple& args) { theRasterizer->reset_clipping(); - + _VERBOSE("RendererAgg::_draw_markers_cache"); args.verify_length(6); - + _VERBOSE("RendererAgg::_draw_markers_cache setting gc"); GCAgg gc = GCAgg(args[0], dpi); - - + + agg::path_storage *ppath; - + swig_type_info * descr = SWIG_TypeQuery("agg::path_storage *"); assert(descr); if (SWIG_ConvertPtr(args[1].ptr(),(void **)(&ppath), descr, 0) == -1) { throw Py::TypeError("Could not convert path_storage"); } facepair_t face = _get_rgba_face(args[2], gc.alpha); - + Py::Object xo = args[3]; Py::Object yo = args[4]; - + PyArrayObject *xa = (PyArrayObject *) PyArray_ContiguousFromObject(xo.ptr(), PyArray_DOUBLE, 1, 1); - + if (xa==NULL) throw Py::TypeError("RendererAgg::_draw_markers_cache expected numerix array"); - - + + PyArrayObject *ya = (PyArrayObject *) PyArray_ContiguousFromObject(yo.ptr(), PyArray_DOUBLE, 1, 1); - + if (ya==NULL) throw Py::TypeError("RendererAgg::_draw_markers_cache expected numerix array"); - + Transformation* mpltransform = static_cast<Transformation*>(args[5].ptr()); - + double a, b, c, d, tx, ty; try { mpltransform->affine_params_api(&a, &b, &c, &d, &tx, &ty); @@ -1931,28 +1931,28 @@ catch(...) { throw Py::ValueError("Domain error on affine_params_api in RendererAgg::_draw_markers_cache"); } - + agg::trans_affine xytrans = agg::trans_affine(a,b,c,d,tx,ty); - + size_t Nx = xa->dimensions[0]; size_t Ny = ya->dimensions[0]; - + if (Nx!=Ny) throw Py::ValueError(Printf("x and y must be equal length arrays; found %d and %d", Nx, Ny).str()); - - + + double heightd = double(height); - - + + ppath->rewind(0); ppath->flip_y(0,0); typedef agg::conv_curve<agg::path_storage> curve_t; curve_t curve(*ppath); - + //maxim's suggestions for cached scanlines agg::scanline_storage_aa8 scanlines; theRasterizer->reset(); - + agg::int8u* fillCache = NULL; unsigned fillSize = 0; if (face.first) { @@ -1962,7 +1962,7 @@ fillCache = new agg::int8u[fillSize]; // or any container scanlines.serialize(fillCache); } - + agg::conv_stroke<curve_t> stroke(curve); stroke.width(gc.linewidth); stroke.line_cap(gc.cap); @@ -1973,10 +1973,10 @@ unsigned strokeSize = scanlines.byte_size(); agg::int8u* strokeCache = new agg::int8u[strokeSize]; // or any container scanlines.serialize(strokeCache); - + theRasterizer->reset_clipping(); - - + + if (gc.cliprect==NULL) { rendererBase->reset_clipping(true); } @@ -1987,13 +1987,13 @@ int h = (int)(gc.cliprect[3]) ; rendererBase->clip_box(l, height-(b+h),l+w, height-b); } - - + + double thisx, thisy; for (size_t i=0; i<Nx; i++) { thisx = *(double *)(xa->data + i*xa->strides[0]); thisy = *(double *)(ya->data + i*ya->strides[0]); - + if (mpltransform->need_nonlinear_api()) try { mpltransform->nonlinear_only_api(&thisx, &thisy); @@ -2001,38 +2001,38 @@ catch(...) { continue; } - + xytrans.transform(&thisx, &thisy); - + thisy = heightd - thisy; //flipy - + thisx = (int)thisx + 0.5; thisy = (int)thisy + 0.5; if (thisx<0) continue; if (thisy<0) continue; if (thisx>width) continue; if (thisy>height) continue; - + agg::serialized_scanlines_adaptor_aa8 sa; agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl; - + if (face.first) { //render the fill sa.init(fillCache, fillSize, thisx, thisy); rendererAA->color(face.second); agg::render_scanlines(sa, sl, *rendererAA); } - + //render the stroke sa.init(strokeCache, strokeSize, thisx, thisy); rendererAA->color(gc.color); agg::render_scanlines(sa, sl, *rendererAA); - + } //for each marker - + Py_XDECREF(xa); Py_XDECREF(ya); - + if (face.first) delete [] fillCache; delete [] strokeCache; @@ -2040,7 +2040,7 @@ //jdh _VERBOSE("RendererAgg::_draw_markers_cache done"); return Py::Object(); - + } @@ -2050,21 +2050,21 @@ RendererAgg::draw_path(const Py::Tuple& args) { //draw_path(gc, rgbFace, path, transform) theRasterizer->reset_clipping(); - + _VERBOSE("RendererAgg::draw_path"); args.verify_length(3); - + GCAgg gc = GCAgg(args[0], dpi); facepair_t face = _get_rgba_face(args[1], gc.alpha); - + agg::path_storage *path; swig_type_info * descr = SWIG_TypeQuery("agg::path_storage *"); assert(descr); if (SWIG_ConvertPtr(args[2].ptr(),(void **)(&path), descr, 0) == -1) throw Py::TypeError("Could not convert path_storage"); - - - + + + double heightd = double(height); agg::path_storage tpath; // the flipped path size_t Nx = path->total_vertices(); @@ -2073,25 +2073,25 @@ bool curvy = false; for (size_t i=0; i<Nx; i++) { - if (cmd==agg::path_cmd_curve3 || cmd==agg::path_cmd_curve4) curvy=true; + if (cmd==agg::path_cmd_curve3 || cmd==agg::path_cmd_curve4) curvy=true; cmd = path->vertex(i, &x, &y); tpath.add_vertex(x, heightd-y, cmd); } set_clipbox_rasterizer(gc.cliprect); _fill_and_stroke(tpath, gc, face, curvy); return Py::Object(); - + } /** - * This is a custom span generator that converts spans in the + * This is a custom span generator that converts spans in the * 8-bit inverted greyscale font buffer to rgba that agg can use. */ template< class ColorT, class ChildGenerator> class font_to_rgba : - public agg::span_generator<ColorT, + public agg::span_generator<ColorT, agg::span_allocator<ColorT> > { public: @@ -2099,16 +2099,16 @@ typedef ColorT color_type; typedef agg::span_allocator<color_type> allocator_type; typedef agg::span_generator< - ColorT, + ColorT, agg::span_allocator<ColorT> > base_type; private: child_type* _gen; allocator_type _alloc; color_type _color; - + public: - font_to_rgba(child_type* gen, color_type color) : + font_to_rgba(child_type* gen, color_type color) : base_type(_alloc), _gen(gen), _color(color) { @@ -2130,7 +2130,7 @@ return base_type::allocator().span(); } - void prepare(unsigned max_span_len) + void prepare(unsigned max_span_len) { _alloc.allocate(max_span_len); _gen->prepare(max_span_len); @@ -2143,19 +2143,19 @@ _VERBOSE("RendererAgg::draw_text"); typedef agg::span_interpolator_linear<> interpolator_type; - typedef agg::span_image_filter_gray<agg::gray8, interpolator_type> + typedef agg::span_image_filter_gray<agg::gray8, interpolator_type> image_span_gen_type; - typedef font_to_rgba<pixfmt::color_type, image_span_gen_type> + typedef font_to_rgba<pixfmt::color_type, image_span_gen_type> span_gen_type; - typedef agg::renderer_scanline_aa<renderer_base, span_gen_type> + typedef agg::renderer_scanline_aa<renderer_base, span_gen_type> renderer_type; - + args.verify_length(5); - + FT2Image *image = static_cast<FT2Image*>(args[0].ptr()); if (!image->get_buffer()) return Py::Object(); - + int x(0),y(0); try { x = Py::Int( args[1] ); @@ -2165,19 +2165,19 @@ //x,y out of range; todo issue warning? return Py::Object(); } - + double angle = Py::Float( args[3] ); GCAgg gc = GCAgg(args[4], dpi); - + set_clipbox_rasterizer(gc.cliprect); const unsigned char* const buffer = image->get_buffer(); agg::rendering_buffer srcbuf - ((agg::int8u*)buffer, image->get_width(), + ((agg::int8u*)buffer, image->get_width(), image->get_height(), image->get_width()); agg::pixfmt_gray8 pixf_img(srcbuf); - + agg::trans_affine mtx; mtx *= agg::trans_affine_translation(0, -(int)image->get_height()); mtx *= agg::trans_affine_rotation(-angle * agg::pi / 180.0); @@ -2198,7 +2198,7 @@ filter.calculate(agg::image_filter_spline36()); interpolator_type interpolator(inv_mtx); agg::span_allocator<agg::gray8> gray_span_allocator; - image_span_gen_type image_span_generator(gray_span_allocator, + image_span_gen_type image_span_generator(gray_span_allocator, srcbuf, 0, interpolator, filter); span_gen_type output_span_generator(&image_span_generator, gc.color); renderer_type ri(*rendererBase, output_span_generator); @@ -2207,11 +2207,11 @@ //rasterizer.add_path(rect2); //agg::render_scanlines(rasterizer, scanline, ri); - + theRasterizer->add_path(rect2); agg::render_scanlines(*theRasterizer, *slineP8, ri); - + return Py::Object(); } @@ -2220,47 +2220,47 @@ RendererAgg::draw_image(const Py::Tuple& args) { _VERBOSE("RendererAgg::draw_image"); args.verify_length(4); - + float x = Py::Float(args[0]); float y = Py::Float(args[1]); Image *image = static_cast<Image*>(args[2].ptr()); - + set_clip_from_bbox(args[3]); - + pixfmt pixf(*(image->rbufOut)); - - + + Py::Tuple empty; image->flipud_out(empty); rendererBase->blend_from(pixf, 0, (int)x, (int)(height-(y+image->rowsOut))); image->flipud_out(empty); - - + + return Py::Object(); - + } Py::Object RendererAgg::write_rgba(const Py::Tuple& args) { _VERBOSE("RendererAgg::write_rgba"); - + args.verify_length(1); std::string fname = Py::String( args[0]); - + std::ofstream of2( fname.c_str(), std::ios::binary|std::ios::out); for (size_t i=0; i<NUMBYTES; i++) { of2.write((char*)&(pixBuffer[i]), sizeof(char)); } return Py::Object(); - + } static void write_png_data(png_structp png_ptr, png_bytep data, png_size_t length) { PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr); PyObject* write_method = PyObject_GetAttrString(py_file_obj, "write"); PyObject_CallFunction(write_method, "s#", data, length); - + // MGDTODO: Check NULL on failure } @@ -2279,9 +2279,9 @@ RendererAgg::write_png(const Py::Tuple& args) { _VERBOSE("RendererAgg::write_png"); - + args.verify_length(1, 2); - + FILE *fp = NULL; Py::Object py_fileobj = Py::Object(args[0]); if (py_fileobj.isString()) { @@ -2301,34 +2301,34 @@ png_bytep *row_pointers = NULL; png_structp png_ptr = NULL; png_infop info_ptr = NULL; - + try { struct png_color_8_struct sig_bit; png_uint_32 row; - + row_pointers = new png_bytep[height]; for (row = 0; row < height; ++row) { row_pointers[row] = pixBuffer + row * width * 4; } - + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (png_ptr == NULL) { throw Py::RuntimeError("Could not create write struct"); } - + info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { throw Py::RuntimeError("Could not create info struct"); } - + if (setjmp(png_ptr->jmpbuf)) { throw Py::RuntimeError("Error building image"); } - + if (fp) { png_init_io(png_ptr, fp); } else { - png_set_write_fn(png_ptr, (void*)py_fileobj.ptr(), + png_set_write_fn(png_ptr, (void*)py_fileobj.ptr(), &write_png_data, &flush_png_data); } png_set_IHDR(png_ptr, info_ptr, @@ -2342,7 +2342,7 @@ size_t dots_per_meter = (size_t)(dpi / (2.54 / 100.0)); png_set_pHYs(png_ptr, info_ptr, dots_per_meter, dots_per_meter, PNG_RESOLUTION_METER); } - + // this a a color image! sig_bit.gray = 0; sig_bit.red = 8; @@ -2351,23 +2351,23 @@ /* if the image has an alpha channel then */ sig_bit.alpha = 8; png_set_sBIT(png_ptr, info_ptr, &sig_bit); - + png_write_info(png_ptr, info_ptr); png_write_image(png_ptr, row_pointers); png_write_end(png_ptr, info_ptr); - + /* Changed calls to png_destroy_write_struct to follow http://www.libpng.org/pub/png/libpng-manual.txt. This ensures the info_ptr memory is released. */ - + } catch (...) { if (fp) fclose(fp); delete [] row_pointers; if (png_ptr && info_ptr) png_destroy_write_struct(&png_ptr, &info_ptr); throw; } - + png_destroy_write_struct(&png_ptr, &info_ptr); delete [] row_pointers; if (fp) fclose(fp); @@ -2379,9 +2379,9 @@ Py::Object RendererAgg::tostring_rgb(const Py::Tuple& args) { //"Return the rendered buffer as an RGB string"; - + _VERBOSE("RendererAgg::tostring_rgb"); - + args.verify_length(0); int row_len = width*3; unsigned char* buf_tmp = new unsigned char[row_len * height]; @@ -2394,10 +2394,10 @@ width, height, row_len); - + agg::color_conv(&renderingBufferTmp, renderingBuffer, agg::color_conv_rgba32_to_rgb24()); - - + + //todo: how to do this with native CXX PyObject* o = Py_BuildValue("s#", buf_tmp, @@ -2410,9 +2410,9 @@ Py::Object RendererAgg::tostring_argb(const Py::Tuple& args) { //"Return the rendered buffer as an RGB string"; - + _VERBOSE("RendererAgg::tostring_argb"); - + args.verify_length(0); int row_len = width*4; unsigned char* buf_tmp = new unsigned char[row_len * height]; @@ -2425,10 +2425,10 @@ width, height, row_len); - + agg::color_conv(&renderingBufferTmp, renderingBuffer, agg::color_conv_rgba32_to_argb32()); - - + + //todo: how to do this with native CXX PyObject* o = Py_BuildValue("s#", buf_tmp, @@ -2440,9 +2440,9 @@ Py::Object RendererAgg::tostring_bgra(const Py::Tuple& args) { //"Return the rendered buffer as an RGB string"; - + _VERBOSE("RendererAgg::tostring_bgra"); - + args.verify_length(0); int row_len = width*4; unsigned char* buf_tmp = new unsigned char[row_len * height]; @@ -2455,10 +2455,10 @@ width, height, row_len); - + agg::color_conv(&renderingBufferTmp, renderingBuffer, agg::color_conv_rgba32_to_bgra32()); - - + + //todo: how to do this with native CXX PyObject* o = Py_BuildValue("s#", buf_tmp, @@ -2470,9 +2470,9 @@ Py::Object RendererAgg::buffer_rgba(const Py::Tuple& args) { //"expose the rendered buffer as Python buffer object, starting from postion x,y"; - + _VERBOSE("RendererAgg::buffer_rgba"); - + args.verify_length(2); int startw = Py::Int(args[0]); int starth = Py::Int(args[1]); @@ -2486,12 +2486,12 @@ Py::Object RendererAgg::clear(const Py::Tuple& args) { //"clear the rendered buffer"; - + _VERBOSE("RendererAgg::clear"); - + args.verify_length(0); rendererBase->clear(agg::rgba(1, 1, 1, 0)); - + return Py::Object(); } @@ -2499,12 +2499,12 @@ agg::rgba RendererAgg::rgb_to_color(const Py::SeqBase<Py::Object>& rgb, double alpha) { _VERBOSE("RendererAgg::rgb_to_color"); - + double r = Py::Float(rgb[0]); double g = Py::Float(rgb[1]); double b = Py::Float(rgb[2]); return agg::rgba(r, g, b, alpha); - + } @@ -2517,8 +2517,8 @@ double p = Py::Float( points ) ; //return (int)(p*PIXELS_PER_INCH/72.0*dpi/72.0)+0.5; return (int)(p*dpi/72.0)+0.5; - - + + } double @@ -2531,10 +2531,10 @@ RendererAgg::~RendererAgg() { - + _VERBOSE("RendererAgg::~RendererAgg"); - - + + delete slineP8; delete slineBin; delete theRasterizer; @@ -2543,7 +2543,7 @@ delete rendererBase; delete pixFmt; delete renderingBuffer; - + delete alphaMask; delete alphaMaskRenderingBuffer; delete [] alphaBuffer; @@ -2552,23 +2552,23 @@ delete rendererBaseAlphaMask; delete rendererAlphaMask; delete scanlineAlphaMask; - + } /* ------------ module methods ------------- */ Py::Object _backend_agg_module::new_renderer (const Py::Tuple &args, const Py::Dict &kws) { - + if (args.length() != 3 ) { throw Py::RuntimeError("Incorrect # of args to RendererAgg(width, height, dpi)."); } - + int debug; if ( kws.hasKey("debug") ) debug = Py::Int( kws["debug"] ); else debug=0; - + int width = Py::Int(args[0]); int height = Py::Int(args[1]); double dpi = Py::Float(args[2]); @@ -2579,10 +2579,10 @@ void BufferRegion::init_type() { behaviors().name("BufferRegion"); behaviors().doc("A wrapper to pass agg buffer objects to and from the python level"); - + add_varargs_method("to_string", &BufferRegion::to_string, "to_string()"); - + } @@ -2590,7 +2590,7 @@ { behaviors().name("RendererAgg"); behaviors().doc("The agg backend extension module"); - + add_varargs_method("draw_rectangle", &RendererAgg::draw_rectangle, "draw_rectangle(gc, rgbFace, l, b, w, h)\n"); add_varargs_method("draw_ellipse", &RendererAgg::draw_ellipse, @@ -2635,11 +2635,11 @@ "clear()"); add_varargs_method("copy_from_bbox", &RendererAgg::copy_from_bbox, "copy_from_bbox(bbox)"); - + add_varargs_method("restore_region", &RendererAgg::restore_region, "restore_region(region)"); - - + + } @@ -2648,12 +2648,12 @@ init_backend_agg(void) { //static _backend_agg_module* _backend_agg = new _backend_agg_module; - + _VERBOSE("init_backend_agg"); - + import_array(); - + static _backend_agg_module* _backend_agg = NULL; _backend_agg = new _backend_agg_module; - + }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2007-11-18 18:59:57
|
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. |
From: <js...@us...> - 2007-11-18 16:45:29
|
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', - 'ortho' : 'Orthographic', - 'geos' : 'Geostationary', - 'sinu' : 'Sinusoidal', - 'moll' : 'Mollweide', - 'robin' : 'Robinson', - 'gnom' : 'Gnomonic', - } - +# unsupported projection error message. _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.append(supported_projections) _unsupported_projection = ''.join(_unsupported_projection) def _validated_ll(param, name, minval, maxval): @@ -191,12 +182,7 @@ class Basemap(object): """ - Set up a basemap with one of 19 supported map projections - (cylindrical equidistant, mercator, polyconic, oblique mercator, - transverse mercator, miller cylindrical, lambert conformal conic, - azimuthal equidistant, equidistant conic, lambert azimuthal equal area, - albers equal area conic, gnomonic, orthographic, sinusoidal, mollweide, - geostationary, robinson, cassini-soldner or stereographic). + Set up a basemap with specified map projection. Doesn't actually draw anything, but sets up the map projection class and creates the coastline, lake river and political boundary data structures in native map projection coordinates. @@ -204,10 +190,8 @@ Useful instance variables: - projection - map projection ('cyl','merc','mill','lcc','eqdc','aea', - 'laea', 'nplaea', 'splaea', 'tmerc', 'omerc', 'cass', 'gnom', 'poly', - 'sinu', 'moll', 'ortho', 'robin', 'aeqd', 'npaeqd', 'spaeqd', 'stere', - 'geos', 'npstere' or 'spstere') + 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) aspect - map aspect ratio (size of y dimension / size of x dimension). @@ -247,11 +231,8 @@ [this example (simpletest.py) plus many others can be found in the examples directory of source distribution. The "OO" version of this example (which does not use pylab) is called "simpletest_oo.py".] - - Contact: Jeff Whitaker <jef...@no...> """ - def __init__(self, llcrnrlon=None, llcrnrlat=None, urcrnrlon=None, urcrnrlat=None, width=None, height=None, @@ -267,7 +248,7 @@ anchor='C', ax=None): # docstring is added after definition - #print "starting: ", time.clock() + # where to put plot in figure (default is 'C' or center) self.anchor = anchor # map projection. @@ -604,6 +585,7 @@ else: coastsegs.append(seg) self.coastsegs = coastsegs + __init__.__doc__ = _Basemap_init_doc def __call__(self,x,y,inverse=False): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-18 16:16:17
|
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 10000,1000,100,10 for resolution - 'c','l','i','h'. + in km^2 will not be plotted. Default 10000,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.path.join(basemap_datadir,name+'_'+self.resolution+'.dat'),'rb') bdatmetafile = open(os.path.join(basemap_datadir,name+'meta_'+self.resolution+'.dat'),'r') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-18 14:31:10
|
Revision: 4371 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4371&view=rev Author: jswhit Date: 2007-11-18 06:31:06 -0800 (Sun, 18 Nov 2007) Log Message: ----------- port over the rest of Eric's changes 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-18 13:32:27 UTC (rev 4370) +++ trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-18 14:31:06 UTC (rev 4371) @@ -12,7 +12,7 @@ from proj import Proj import numpy as npy from numpy import linspace, squeeze, ma -from matplotlib.cbook import popd, is_scalar +from matplotlib.cbook import is_scalar, dedent from shapelib import ShapeFile import _geos @@ -21,77 +21,10 @@ __version__ = '0.9.7' -class Basemap(object): - - """ - Set up a basemap with one of 19 supported map projections - (cylindrical equidistant, mercator, polyconic, oblique mercator, - transverse mercator, miller cylindrical, lambert conformal conic, - azimuthal equidistant, equidistant conic, lambert azimuthal equal area, - albers equal area conic, gnomonic, orthographic, sinusoidal, mollweide, - geostationary, robinson, cassini-soldner or stereographic). - Doesn't actually draw anything, but sets up the map projection class and - creates the coastline, lake river and political boundary data - structures in native map projection coordinates. - Uses a pyrex interface to C-code from proj.4 (http://proj.maptools.org). - - Useful instance variables: - - projection - map projection ('cyl','merc','mill','lcc','eqdc','aea', - 'laea', 'nplaea', 'splaea', 'tmerc', 'omerc', 'cass', 'gnom', 'poly', - 'sinu', 'moll', 'ortho', 'robin', 'aeqd', 'npaeqd', 'spaeqd', 'stere', - 'geos', 'npstere' or 'spstere') - (projections prefixed with 'np' or 'sp' are special case polar-centric - versions of the parent projection) - 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. - urcrnrlon - longitude of upper right hand corner of the desired map domain. - urcrnrlon - latitude of upper right hand corner of the desired map domain. - llcrnrx,llcrnry,urcrnrx,urcrnry - corners of map domain in projection coordinates. - rmajor,rminor - equatorial and polar radii of ellipsoid used (in meters). - resolution - resolution of boundary dataset being used ('c' for crude, - 'l' for low, etc.). If None, no boundary dataset is associated with the - Basemap instance. - srs - a string representing the 'spatial reference system' for the map - projection as defined by PROJ.4. - - Example Usage: - ->>> from matplotlib.toolkits.basemap import Basemap ->>> from pylab import load, meshgrid, title, arange, show ->>> # read in topo data (on a regular lat/lon grid) ->>> etopo = load('etopo20data.gz') ->>> lons = load('etopo20lons.gz') ->>> lats = load('etopo20lats.gz') ->>> # create Basemap instance for Robinson projection. ->>> m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1])) ->>> # compute native map projection coordinates for lat/lon grid. ->>> x, y = m(*meshgrid(lons,lats)) ->>> # make filled contour plot. ->>> cs = m.contourf(x,y,etopo,30,cmap=cm.jet) ->>> m.drawcoastlines() # draw coastlines ->>> m.drawmapboundary() # draw a line around the map region ->>> m.drawparallels(arange(-90.,120.,30.),labels=[1,0,0,0]) # draw parallels ->>> m.drawmeridians(arange(0.,420.,60.),labels=[0,0,0,1]) # draw meridians ->>> title('Robinson Projection') # add a title ->>> show() - - [this example (simpletest.py) plus many others can be found in the - examples directory of source distribution. The "OO" version of this - example (which does not use pylab) is called "simpletest_oo.py".] - - Contact: Jeff Whitaker <jef...@no...> - """ - - def __init__(self,llcrnrlon=None,llcrnrlat=None, - urcrnrlon=None,urcrnrlat=None,\ - width=None,height=None,\ - projection='cyl',resolution='c',area_thresh=None,rsphere=6370997.0,\ - lat_ts=None,lat_1=None,lat_2=None,lat_0=None,lon_0=None,\ - lon_1=None,lon_2=None,suppress_ticks=True,\ - satellite_height=None,boundinglat=None,anchor='C',ax=None): - """ +# 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. +_Basemap_init_doc = """ create a Basemap instance. arguments: @@ -127,19 +60,19 @@ lon_0 - center of desired map domain (in degrees). lat_0 - center of desired map domain (in degrees). - For 'sinu', 'moll', 'npstere', 'spstere', 'nplaea', 'splaea', 'nplaea', - 'splaea', 'npaeqd', 'spaeqd' or 'robin', the values of - llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat,width and height are ignored (because - either they are computed internally, or entire globe is always plotted). For the - cylindrical projections ('cyl','merc' and 'mill'), the default is to use - llcrnrlon=-180,llcrnrlat=-90, urcrnrlon=180 and urcrnrlat=90). For all other + For 'sinu', 'moll', 'npstere', 'spstere', 'nplaea', 'splaea', 'nplaea', + 'splaea', 'npaeqd', 'spaeqd' or 'robin', the values of + llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat,width and height are ignored (because + either they are computed internally, or entire globe is always plotted). For the + cylindrical projections ('cyl','merc' and 'mill'), the default is to use + llcrnrlon=-180,llcrnrlat=-90, urcrnrlon=180 and urcrnrlat=90). For all other projections except 'ortho' and 'geos', either the lat/lon values of the corners or width and height must be specified by the user. For 'ortho' and 'geos', the lat/lon values of the corners may be specified, 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), 'f' (full) or None. + 'l' (low), 'i' (intermediate), 'h' (high), or None. Default is 'c'. 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% @@ -150,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 10000,1000,100,10,1 for resolution - 'c','l','i','h','f'. + in km^2 will not be plotted. Default 10000,1000,100,10 for resolution + 'c','l','i','h'. rsphere - radius of the sphere used to define map projection (default 6370997 meters, close to the arithmetic mean radius of the earth). If @@ -185,7 +118,7 @@ The following parameters are map projection parameters which all default to None. Not all parameters are used by all projections, some are ignored. - lat_ts - latitude of natural origin (used for mercator, and + lat_ts - latitude of natural origin (used for mercator, and optionally for stereographic projection). lat_1 - first standard parallel for lambert conformal, albers equal area projection and equidistant conic projections. Latitude of one @@ -195,13 +128,13 @@ lat_2 - second standard parallel for lambert conformal, albers equal area projection and equidistant conic projections. Latitude of one of the two points on the projection centerline for oblique mercator. - If lat_2 is not given, it is set to lat_1 for + If lat_2 is not given, it is set to lat_1 for lambert conformal, albers equal area and equidistant conic. lon_1 - longitude of one of the two points on the projection centerline for oblique mercator. lon_2 - longitude of one of the two points on the projection centerline for oblique mercator. - lat_0 - central latitude (y-axis origin) - used by all projections, + lat_0 - central latitude (y-axis origin) - used by all projections, lon_0 - central meridian (x-axis origin) - used by all projections, boundinglat - bounding latitude for pole-centered projections (npstere,spstere, nplaea,splaea,npaeqd,spaeqd). These projections are square regions centered @@ -209,10 +142,146 @@ 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', + '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' : 'Nouth-Polar Stereographic', + 'spstere' : 'South-Polar Stereographic', + 'cass' : 'Cassini-Soldner', + 'poly' : 'Polyconic', + 'ortho' : 'Orthographic', + 'geos' : 'Geostationary', + 'sinu' : 'Sinusoidal', + 'moll' : 'Mollweide', + 'robin' : 'Robinson', + 'gnom' : 'Gnomonic', + } + +def _validated_ll(param, name, minval, maxval): + param = float(param) + if param > maxval or param < minval: + raise ValueError('%s must be between %f and %f degrees' % + (name, minval, maxval)) + return param + +def _insert_validated(d, param, name, minval, maxval): + if param is not None: + d[name] = _validated_ll(param, name, minval, maxval) + +class Basemap(object): + """ + Set up a basemap with one of 19 supported map projections + (cylindrical equidistant, mercator, polyconic, oblique mercator, + transverse mercator, miller cylindrical, lambert conformal conic, + azimuthal equidistant, equidistant conic, lambert azimuthal equal area, + albers equal area conic, gnomonic, orthographic, sinusoidal, mollweide, + geostationary, robinson, cassini-soldner or stereographic). + Doesn't actually draw anything, but sets up the map projection class and + creates the coastline, lake river and political boundary data + structures in native map projection coordinates. + Uses a pyrex interface to C-code from proj.4 (http://proj.maptools.org). + + Useful instance variables: + + projection - map projection ('cyl','merc','mill','lcc','eqdc','aea', + 'laea', 'nplaea', 'splaea', 'tmerc', 'omerc', 'cass', 'gnom', 'poly', + 'sinu', 'moll', 'ortho', 'robin', 'aeqd', 'npaeqd', 'spaeqd', 'stere', + 'geos', 'npstere' or 'spstere') + (projections prefixed with 'np' or 'sp' are special case polar-centric + versions of the parent projection) + 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. + urcrnrlon - longitude of upper right hand corner of the desired map domain. + urcrnrlon - latitude of upper right hand corner of the desired map domain. + llcrnrx,llcrnry,urcrnrx,urcrnry - corners of map domain in projection coordinates. + rmajor,rminor - equatorial and polar radii of ellipsoid used (in meters). + resolution - resolution of boundary dataset being used ('c' for crude, + 'l' for low, etc.). If None, no boundary dataset is associated with the + Basemap instance. + srs - a string representing the 'spatial reference system' for the map + projection as defined by PROJ.4. + + Example Usage: + + >>> from matplotlib.toolkits.basemap import Basemap + >>> from pylab import load, meshgrid, title, arange, show + >>> # read in topo data (on a regular lat/lon grid) + >>> etopo = load('etopo20data.gz') + >>> lons = load('etopo20lons.gz') + >>> lats = load('etopo20lats.gz') + >>> # create Basemap instance for Robinson projection. + >>> m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1])) + >>> # compute native map projection coordinates for lat/lon grid. + >>> x, y = m(*meshgrid(lons,lats)) + >>> # make filled contour plot. + >>> cs = m.contourf(x,y,etopo,30,cmap=cm.jet) + >>> m.drawcoastlines() # draw coastlines + >>> m.drawmapboundary() # draw a line around the map region + >>> m.drawparallels(arange(-90.,120.,30.),labels=[1,0,0,0]) # draw parallels + >>> m.drawmeridians(arange(0.,420.,60.),labels=[0,0,0,1]) # draw meridians + >>> title('Robinson Projection') # add a title + >>> show() + + [this example (simpletest.py) plus many others can be found in the + examples directory of source distribution. The "OO" version of this + example (which does not use pylab) is called "simpletest_oo.py".] + + Contact: Jeff Whitaker <jef...@no...> + """ + + + def __init__(self, llcrnrlon=None, llcrnrlat=None, + urcrnrlon=None, urcrnrlat=None, + width=None, height=None, + projection='cyl', resolution='c', + area_thresh=None, rsphere=6370997.0, + lat_ts=None, + lat_1=None, lat_2=None, + lat_0=None, lon_0=None, + lon_1=None, lon_2=None, + suppress_ticks=True, + satellite_height=None, + boundinglat=None, + anchor='C', + ax=None): + # docstring is added after definition + #print "starting: ", time.clock() # where to put plot in figure (default is 'C' or center) self.anchor = anchor # map projection. @@ -238,223 +307,91 @@ # set units to meters. projparams['units']='m' # check for sane values of lon_0, lat_0, lat_ts, lat_1, lat_2 - if lat_0 is not None: - if lat_0 > 90. or lat_0 < -90.: - raise ValueError, 'lat_0 must be between -90 and +90 degrees' - else: - projparams['lat_0'] = lat_0 - if lon_0 is not None: - if lon_0 < -720. or lon_0 > 720.: - raise ValueError, 'lon_0 must be between -720 and +720 degrees' - else: - projparams['lon_0'] = lon_0 - if lon_1 is not None: - if lon_1 < -720. or lon_1 > 720.: - raise ValueError, 'lon_1 must be between -720 and +720 degrees' - else: - projparams['lon_1'] = lon_1 - if lon_2 is not None: - if lon_2 < -720. or lon_2 > 720.: - raise ValueError, 'lon_2 must be between -720 and +720 degrees' - else: - projparams['lon_2'] = lon_2 - if lat_1 is not None: - if lat_1 > 90. or lat_1 < -90.: - raise ValueError, 'lat_1 must be between -90 and +90 degrees' - else: - projparams['lat_1'] = lat_1 - if lat_2 is not None: - if lat_2 > 90. or lat_2 < -90.: - raise ValueError, 'lat_2 must be between -90 and +90 degrees' - else: - projparams['lat_2'] = lat_2 - if lat_ts is not None: - if lat_ts > 90. or lat_ts < -90.: - raise ValueError, 'lat_ts must be between -90 and +90 degrees' - else: - projparams['lat_ts'] = lat_ts + _insert_validated(projparams, lat_0, 'lat_0', -90, 90) + _insert_validated(projparams, lat_1, 'lat_1', -90, 90) + _insert_validated(projparams, lat_2, 'lat_2', -90, 90) + _insert_validated(projparams, lat_ts, 'lat_ts', -90, 90) + _insert_validated(projparams, lon_0, 'lon_0', -360, 720) + _insert_validated(projparams, lon_1, 'lon_1', -360, 720) + _insert_validated(projparams, lon_2, 'lon_2', -360, 720) if satellite_height is not None: projparams['h'] = satellite_height + 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) - self.urcrnrlon = float(urcrnrlon) - self.urcrnrlat = float(urcrnrlat) - # check values of urcrnrlon,urcrnrlat and llcrnrlon,llcrnrlat - if self.urcrnrlat > 90.0 or self.llcrnrlat > 90.0: - raise ValueError, 'urcrnrlat and llcrnrlat must be less than 90' - if self.urcrnrlat < -90.0 or self.llcrnrlat < -90.0: - raise ValueError, 'urcrnrlat and llcrnrlat must be greater than -90' - if self.urcrnrlon > 720. or self.llcrnrlon > 720.: - raise ValueError, 'urcrnrlon and llcrnrlon must be less than 720' - if self.urcrnrlon < -360. or self.llcrnrlon < -360.: - raise ValueError, 'urcrnrlon and llcrnrlon must be greater than -360' - # for each of the supported projections, compute lat/lon of domain corners + self.llcrnrlon = _validated_ll(llcrnrlon, 'llcrnrlon', -360, 720) + self.urcrnrlon = _validated_ll(urcrnrlon, 'urcrnrlon', -360, 720) + self.llcrnrlat = _validated_ll(llcrnrlat, 'llcrnrlat', -90, 90) + self.urcrnrlat = _validated_ll(urcrnrlat, 'urcrnrlat', -90, 90) + + # for each of the supported projections, + # compute lat/lon of domain corners # and set values in projparams dict as needed. - if projection == 'lcc': + if projection in ['lcc', 'eqdc', 'aea']: # if lat_0 is given, but not lat_1, # set lat_1=lat_0 if lat_1 is None and lat_0 is not None: 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 Lambert Conformal basemap (lat_2 is optional)' + 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: 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: - if lon_0 is None or lat_0 is None: - raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' - llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) - self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat - self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat - - elif projection == 'eqdc': - # if lat_0 is given, but not lat_1, - # set lat_1=lat_0 - if lat_1 is None and lat_0 is not None: - 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 Equidistant Conic basemap (lat_2 is optional)' - if lat_2 is None: - projparams['lat_2'] = lat_1 - 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: - if lon_0 is None or lat_0 is None: - raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' - llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) - self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat - self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat - elif projection == 'aea': - # if lat_0 is given, but not lat_1, - # set lat_1=lat_0 - if lat_1 is None and lat_0 is not None: - 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 Albers Equal Area basemap (lat_2 is optional)' - if lat_2 is None: - projparams['lat_2'] = lat_1 - 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: - if lon_0 is None or lat_0 is None: - raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' - llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) - self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat - self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat + if lon_0 is None or lat_0 is None: + raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' + llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) + self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat + self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat + + # skipping over the following for now; it can be beautified and + # consolidated later 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 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: - if lon_0 is None or lat_0 is None: - raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' - llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) - self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat - self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat - elif projection == 'spstere': + if lon_0 is None or lat_0 is None: + raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' + llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) + self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat + self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat + elif projection in ['spstere', 'npstere', + 'splaea', 'nplaea', + 'spaeqd', 'npaeqd']: if boundinglat is None or lon_0 is None: - raise ValueError, 'must specify boundinglat and lon_0 for South-Polar Stereographic basemap' - projparams['lat_ts'] = -90. - projparams['lat_0'] = -90. - projparams['proj'] = 'stere' - self.llcrnrlon = lon_0+45. - self.urcrnrlon = lon_0-135. + raise ValueError('must specify boundinglat and lon_0 for %(projection) basemap' % projnames) + if projection[0] == 's': + sgn = -1 + else: + sgn = 1 + rootproj = projection[2:] + projparams['proj'] = rootproj + if rootproj == 'stere': + projparams['lat_ts'] = sgn * 90. + projparams['lat_0'] = sgn * 90. + self.llcrnrlon = lon_0 - sgn*45. + self.urcrnrlon = lon_0 + sgn*135. proj = pyproj.Proj(projparams) x,y = proj(lon_0,boundinglat) lon,self.llcrnrlat = proj(math.sqrt(2.)*y,0.,inverse=True) self.urcrnrlat = self.llcrnrlat if width is not None or height is not None: print 'warning: width and height keywords ignored for %s projection' % self.projection - elif projection == 'npstere': - if boundinglat is None or lon_0 is None: - raise ValueError, 'must specify boundinglat and lon_0 for North-Polar Stereographic basemap' - projparams['lat_ts'] = 90. - projparams['lat_0'] = 90. - projparams['proj'] = 'stere' - self.llcrnrlon = lon_0-45. - self.urcrnrlon = lon_0+135. - proj = pyproj.Proj(projparams) - x,y = proj(lon_0,boundinglat) - lon,self.llcrnrlat = proj(math.sqrt(2.)*y,0.,inverse=True) - self.urcrnrlat = self.llcrnrlat - if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection - elif projection == 'splaea': - if boundinglat is None or lon_0 is None: - raise ValueError, 'must specify boundinglat and lon_0 for South-Polar Lambert Azimuthal basemap' - projparams['lat_0'] = -90. - projparams['proj'] = 'laea' - self.llcrnrlon = lon_0+45. - self.urcrnrlon = lon_0-135. - proj = pyproj.Proj(projparams) - x,y = proj(lon_0,boundinglat) - lon,self.llcrnrlat = proj(math.sqrt(2.)*y,0.,inverse=True) - self.urcrnrlat = self.llcrnrlat - if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection - elif projection == 'nplaea': - if boundinglat is None or lon_0 is None: - raise ValueError, 'must specify boundinglat and lon_0 for North-Polar Lambert Azimuthal basemap' - projparams['lat_0'] = 90. - projparams['proj'] = 'laea' - self.llcrnrlon = lon_0-45. - self.urcrnrlon = lon_0+135. - proj = pyproj.Proj(projparams) - x,y = proj(lon_0,boundinglat) - lon,self.llcrnrlat = proj(math.sqrt(2.)*y,0.,inverse=True) - self.urcrnrlat = self.llcrnrlat - if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection - elif projection == 'spaeqd': - if boundinglat is None or lon_0 is None: - raise ValueError, 'must specify boundinglat and lon_0 for South-Polar Azimuthal Equidistant basemap' - projparams['lat_0'] = -90. - projparams['proj'] = 'aeqd' - self.llcrnrlon = lon_0+45. - self.urcrnrlon = lon_0-135. - proj = pyproj.Proj(projparams) - x,y = proj(lon_0,boundinglat) - lon,self.llcrnrlat = proj(math.sqrt(2.)*y,0.,inverse=True) - self.urcrnrlat = self.llcrnrlat - if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection - elif projection == 'npaeqd': - if boundinglat is None or lon_0 is None: - raise ValueError, 'must specify boundinglat and lon_0 for North-Polar Azimuthal Equidistant basemap' - projparams['lat_0'] = 90. - projparams['proj'] = 'aeqd' - self.llcrnrlon = lon_0-45. - self.urcrnrlon = lon_0+135. - proj = pyproj.Proj(projparams) - x,y = proj(lon_0,boundinglat) - lon,self.llcrnrlat = proj(math.sqrt(2.)*y,0.,inverse=True) - self.urcrnrlat = self.llcrnrlat - if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection 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 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: - if lon_0 is None or lat_0 is None: - raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' - llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) - self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat - self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat + if lon_0 is None or lat_0 is None: + raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' + llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) + self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat + self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat elif projection == 'merc': if lat_ts is None: raise ValueError, 'must specify lat_ts for Mercator basemap' @@ -479,13 +416,12 @@ 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: - if lon_0 is None or lat_0 is None: - raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' - llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) - self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat - self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat - + if lon_0 is None or lat_0 is None: + raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' + llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) + self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat + self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat + elif projection == 'ortho': if not projparams.has_key('R'): raise ValueError, 'orthographic projection only works for perfect spheres - not ellipsoids' @@ -547,12 +483,11 @@ 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: - if lon_0 is None or lat_0 is None: - raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' - llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) - self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat - self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat + if lon_0 is None or lat_0 is None: + raise ValueError, 'must specify lon_0 and lat_0 when using width, height to specify projection region' + llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) + self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat + self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat elif projection == 'mill': if not using_corners: llcrnrlon = -180. @@ -574,22 +509,7 @@ if width is not None or height is not None: print 'warning: width and height keywords ignored for %s projection' % self.projection else: - raise ValueError, """ - 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'""" % projection + raise ValueError(_unsupported_projection % projection) # initialize proj4 proj = Proj(projparams,self.llcrnrlon,self.llcrnrlat,self.urcrnrlon,self.urcrnrlat) @@ -701,34 +621,37 @@ def __call__(self,x,y,inverse=False): """ - Calling a Basemap class instance with the arguments lon, lat will - convert lon/lat (in degrees) to x/y native map projection - coordinates (in meters). If optional keyword 'inverse' is - True (default is False), the inverse transformation from x/y - to lon/lat is performed. + Calling a Basemap class instance with the arguments lon, lat will + convert lon/lat (in degrees) to x/y native map projection + coordinates (in meters). If optional keyword 'inverse' is + True (default is False), the inverse transformation from x/y + to lon/lat is performed. - For cylindrical equidistant projection ('cyl'), this - does nothing (i.e. x,y == lon,lat). + For cylindrical equidistant projection ('cyl'), this + does nothing (i.e. x,y == lon,lat). - For non-cylindrical projections, the inverse transformation - always returns longitudes between -180 and 180 degrees. For - cylindrical projections (self.projection == 'cyl','mill' or 'merc') - the inverse transformation will return longitudes between - self.llcrnrlon and self.llcrnrlat. + For non-cylindrical projections, the inverse transformation + always returns longitudes between -180 and 180 degrees. For + cylindrical projections (self.projection == 'cyl','mill' or 'merc') + the inverse transformation will return longitudes between + self.llcrnrlon and self.llcrnrlat. - input arguments lon, lat can be either scalar floats or N arrays. + input arguments lon, lat can be either scalar floats or N arrays. """ return self.projtran(x,y,inverse=inverse) def makegrid(self,nx,ny,returnxy=False): """ - return arrays of shape (ny,nx) containing lon,lat coordinates of - an equally spaced native projection grid. - if returnxy = True, the x,y values of the grid are returned also. + return arrays of shape (ny,nx) containing lon,lat coordinates of + an equally spaced native projection grid. + if returnxy = True, the x,y values of the grid are returned also. """ return self.projtran.makegrid(nx,ny,returnxy=returnxy) def _readboundarydata(self,name): + """ + 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 @@ -925,7 +848,7 @@ def _getmapboundary(self): """ - create map boundary polygon (in lat/lon and x/y coordinates) + create map boundary polygon (in lat/lon and x/y coordinates) """ nx = 100 ny = 100 @@ -1043,8 +966,9 @@ def drawmapboundary(self,color='k',linewidth=1.0,ax=None): """ - draw boundary around map projection region. If ax=None (default), - default axis instance is used, otherwise specified axis instance is used. + draw boundary around map projection region. If ax=None (default), + default axis instance is used, otherwise specified axis + instance is used. """ # get current axes instance (if none specified). if ax is None and self.ax is None: @@ -1105,15 +1029,15 @@ def fillcontinents(self,color='0.8',ax=None,zorder=None): """ - Fill continents. + Fill continents. - color - color to fill continents (default gray). - ax - axes instance (overrides default axes instance). - zorder - sets the zorder for the continent polygons (if not specified, - uses default zorder for a Polygon patch). Set to zero if you want to paint - over the filled continents). + color - color to fill continents (default gray). + ax - axes instance (overrides default axes instance). + zorder - sets the zorder for the continent polygons (if not specified, + uses default zorder for a Polygon patch). Set to zero if you want to paint + over the filled continents). - After filling continents, lakes are re-filled with axis background color. + After filling continents, lakes are re-filled with axis background color. """ if self.resolution is None: raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' @@ -1161,14 +1085,14 @@ def drawcoastlines(self,linewidth=1.,color='k',antialiased=1,ax=None,zorder=None): """ - Draw coastlines. + Draw coastlines. - linewidth - coastline width (default 1.) - color - coastline color (default black) - antialiased - antialiasing switch for coastlines (default True). - ax - axes instance (overrides default axes instance) - zorder - sets the zorder for the coastlines (if not specified, - uses default zorder for LineCollections). + linewidth - coastline width (default 1.) + color - coastline color (default black) + antialiased - antialiasing switch for coastlines (default True). + ax - axes instance (overrides default axes instance) + zorder - sets the zorder for the coastlines (if not specified, + uses default zorder for LineCollections). """ if self.resolution is None: raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' @@ -1192,14 +1116,14 @@ def drawcountries(self,linewidth=0.5,color='k',antialiased=1,ax=None,zorder=None): """ - Draw country boundaries. + Draw country boundaries. - linewidth - country boundary line width (default 0.5) - color - country boundary line color (default black) - antialiased - antialiasing switch for country boundaries (default True). - ax - axes instance (overrides default axes instance) - zorder - sets the zorder for the country boundaries (if not specified, - uses default zorder for LineCollections). + linewidth - country boundary line width (default 0.5) + color - country boundary line color (default black) + antialiased - antialiasing switch for country boundaries (default True). + ax - axes instance (overrides default axes instance) + zorder - sets the zorder for the country boundaries (if not specified, + uses default zorder for LineCollections). """ if self.resolution is None: raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' @@ -1227,14 +1151,14 @@ def drawstates(self,linewidth=0.5,color='k',antialiased=1,ax=None,zorder=None): """ - Draw state boundaries in Americas. + Draw state boundaries in Americas. - linewidth - state boundary line width (default 0.5) - color - state boundary line color (default black) - antialiased - antialiasing switch for state boundaries (default True). - ax - axes instance (overrides default axes instance) - zorder - sets the zorder for the state boundaries (if not specified, - uses default zorder for LineCollections). + linewidth - state boundary line width (default 0.5) + color - state boundary line color (default black) + antialiased - antialiasing switch for state boundaries (default True). + ax - axes instance (overrides default axes instance) + zorder - sets the zorder for the state boundaries (if not specified, + uses default zorder for LineCollections). """ if self.resolution is None: raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' @@ -1262,14 +1186,14 @@ def drawrivers(self,linewidth=0.5,color='k',antialiased=1,ax=None,zorder=None): """ - Draw major rivers. + Draw major rivers. - linewidth - river boundary line width (default 0.5) - color - river boundary line color (default black) - antialiased - antialiasing switch for river boundaries (default True). - ax - axes instance (overrides default axes instance) - zorder - sets the zorder for the rivers (if not specified, - uses default zorder for LineCollections). + linewidth - river boundary line width (default 0.5) + color - river boundary line color (default black) + antialiased - antialiasing switch for river boundaries (default True). + ax - axes instance (overrides default axes instance) + zorder - sets the zorder for the rivers (if not specified, + uses default zorder for LineCollections). """ if self.resolution is None: raise AttributeError, 'there are no boundary datasets associated with this Basemap instance' @@ -1298,40 +1222,40 @@ def readshapefile(self,shapefile,name,drawbounds=True,zorder=None, linewidth=0.5,color='k',antialiased=1,ax=None): """ - read in shape file, draw boundaries on map. + read in shape file, draw boundaries on map. - Restrictions: - - Assumes shapes are 2D - - vertices must be in geographic (lat/lon) coordinates. + Restrictions: + - Assumes shapes are 2D + - vertices must be in geographic (lat/lon) coordinates. - shapefile - path to shapefile components. Example: - shapefile='/home/jeff/esri/world_borders' assumes that - world_borders.shp, world_borders.shx and world_borders.dbf - live in /home/jeff/esri. - name - name for Basemap attribute to hold the shapefile - vertices in native map projection coordinates. - Class attribute name+'_info' is a list of dictionaries, one - for each shape, containing attributes of each shape from dbf file. - For example, if name='counties', self.counties - will be a list of vertices for each shape in map projection - coordinates and self.counties_info will be a list of dictionaries - with shape attributes. Rings in individual shapes are split out - into separate polygons. Additional keys - 'RINGNUM' and 'SHAPENUM' are added to shape attribute dictionary. - drawbounds - draw boundaries of shapes (default True) - zorder = shape boundary zorder (if not specified, default for LineCollection - is used). - linewidth - shape boundary line width (default 0.5) - color - shape boundary line color (default black) - antialiased - antialiasing switch for shape boundaries (default True). - ax - axes instance (overrides default axes instance) + shapefile - path to shapefile components. Example: + shapefile='/home/jeff/esri/world_borders' assumes that + world_borders.shp, world_borders.shx and world_borders.dbf + live in /home/jeff/esri. + name - name for Basemap attribute to hold the shapefile + vertices in native map projection coordinates. + Class attribute name+'_info' is a list of dictionaries, one + for each shape, containing attributes of each shape from dbf file. + For example, if name='counties', self.counties + will be a list of vertices for each shape in map projection + coordinates and self.counties_info will be a list of dictionaries + with shape attributes. Rings in individual shapes are split out + into separate polygons. Additional keys + 'RINGNUM' and 'SHAPENUM' are added to shape attribute dictionary. + drawbounds - draw boundaries of shapes (default True) + zorder = shape boundary zorder (if not specified, default for LineCollection + is used). + linewidth - shape boundary line width (default 0.5) + color - shape boundary line color (default black) + antialiased - antialiasing switch for shape boundaries (default True). + ax - axes instance (overrides default axes instance) - returns a tuple (num_shapes, type, min, max) containing shape file info. - num_shapes is the number of shapes, type is the type code (one of - the SHPT* constants defined in the shapelib module, see - http://shapelib.maptools.org/shp_api.html) and min and - max are 4-element lists with the minimum and maximum values of the - vertices. + returns a tuple (num_shapes, type, min, max) containing shape file info. + num_shapes is the number of shapes, type is the type code (one of + the SHPT* constants defined in the shapelib module, see + http://shapelib.maptools.org/shp_api.html) and min and + max are 4-element lists with the minimum and maximum values of the + vertices. """ # open shapefile, read vertices for each object, convert # to map projection coordinates (only works for 2D shape types). @@ -1355,11 +1279,11 @@ for ring in range(rings): lons, lats = zip(*verts[ring]) if max(lons) > 721. or min(lons) < -721. or max(lats) > 91. or min(lats) < -91: - msg=""" -shapefile must have lat/lon vertices - it looks like this one has vertices -in map projection coordinates. You can convert the shapefile to geographic -coordinates using the shpproj utility from the shapelib tools -(http://shapelib.maptools.org/shapelib-tools.html)""" + msg=dedent(""" + shapefile must have lat/lon vertices - it looks like this one has vertices + in map projection coordinates. You can convert the shapefile to geographic + coordinates using the shpproj utility from the shapelib tools + (http://shapelib.maptools.org/shapelib-tools.html)""") raise ValueError,msg x, y = self(lons, lats) shpsegs.append(zip(x,y)) @@ -1400,32 +1324,32 @@ linestyle='--',dashes=[1,1],labels=[0,0,0,0],labelstyle=None, \ fmt='%g',xoffset=None,yoffset=None,ax=None,**kwargs): """ - draw parallels (latitude lines). + draw parallels (latitude lines). - circles - list containing latitude values to draw (in degrees). - color - color to draw parallels (default black). - linewidth - line width for parallels (default 1.) - zorder - sets the zorder for parallels (if not specified, - uses default zorder for Line2D class). - linestyle - line style for parallels (default '--', i.e. dashed). - dashes - dash pattern for parallels (default [1,1], i.e. 1 pixel on, - 1 pixel off). - labels - list of 4 values (default [0,0,0,0]) that control whether - parallels are labelled where they intersect the left, right, top or - bottom of the plot. For example labels=[1,0,0,1] will cause parallels - to be labelled where they intersect the left and bottom of the plot, - but not the right and top. - labelstyle - if set to "+/-", north and south latitudes are labelled - with "+" and "-", otherwise they are labelled with "N" and "S". - fmt is a format string to format the parallel labels (default '%g'). - xoffset - label offset from edge of map in x-direction - (default is 0.01 times width of map in map projection coordinates). - yoffset - label offset from edge of map in y-direction - (default is 0.01 times height of map in map projection coordinates). - ax - axes instance (overrides default axes instance) + circles - list containing latitude values to draw (in degrees). + color - color to draw parallels (default black). + linewidth - line width for parallels (default 1.) + zorder - sets the zorder for parallels (if not specified, + uses default zorder for Line2D class). + linestyle - line style for parallels (default '--', i.e. dashed). + dashes - dash pattern for parallels (default [1,1], i.e. 1 pixel on, + 1 pixel off). + labels - list of 4 values (default [0,0,0,0]) that control whether + parallels are labelled where they intersect the left, right, top or + bottom of the plot. For example labels=[1,0,0,1] will cause parallels + to be labelled where they intersect the left and bottom of the plot, + but not the right and top. + labelstyle - if set to "+/-", north and south latitudes are labelled + with "+" and "-", otherwise they are labelled with "N" and "S". + fmt is a format string to format the parallel labels (default '%g'). + xoffset - label offset from edge of map in x-direction + (default is 0.01 times width of map in map projection coordinates). + yoffset - label offset from edge of map in y-direction + (default is 0.01 times height of map in map projection coordinates). + ax - axes instance (overrides default axes instance) - additional keyword arguments control text properties for labels (see - pylab.text documentation) + additional keyword arguments control text properties for labels (see + pylab.text documentation) """ # get current axes instance (if none specified). if ax is None and self.ax is None: @@ -1620,32 +1544,32 @@ linestyle='--',dashes=[1,1],labels=[0,0,0,0],labelstyle=None,\ fmt='%g',xoffset=None,yoffset=None,ax=None,**kwargs): """ - draw meridians (longitude lines). + draw meridians (longitude lines). - meridians - list containing longitude values to draw (in degrees). - color - color to draw meridians (default black). - linewidth - line width for meridians (default 1.) - zorder - sets the zorder for meridians (if not specified, - uses default zorder for Line2D class). - linestyle - line style for meridians (default '--', i.e. dashed). - dashes - dash pattern for meridians (default [1,1], i.e. 1 pixel on, - 1 pixel off). - labels - list of 4 values (default [0,0,0,0]) that control whether - meridians are labelled where they intersect the left, right, top or - bottom of the plot. For example labels=[1,0,0,1] will cause meridians - to be labelled where they intersect the left and bottom of the plot, - but not the right and top. - labelstyle - if set to "+/-", east and west longitudes are labelled - with "+" and "-", otherwise they are labelled with "E" and "W". - fmt is a format string to format the meridian labels (default '%g'). - xoffset - label offset from edge of map in x-direction - (default is 0.01 times width of map in map projection coordinates). - yoffset - label offset from edge of map in y-direction - (default is 0.01 times height of map in map projection coordinates). - ax - axes instance (overrides default axes instance) + meridians - list containing longitude values to draw (in degrees). + color - color to draw meridians (default black). + linewidth - line width for meridians (default 1.) + zorder - sets the zorder for meridians (if not specified, + uses default zorder for Line2D class). + linestyle - line style for meridians (default '--', i.e. dashed). + dashes - dash pattern for meridians (default [1,1], i.e. 1 pixel on, + 1 pixel off). + labels - list of 4 values (default [0,0,0,0]) that control whether + meridians are labelled where they intersect the left, right, top or + bottom of the plot. For example labels=[1,0,0,1] will cause meridians + to be labelled where they intersect the left and bottom of the plot, + but not the right and top. + labelstyle - if set to "+/-", east and west longitudes are labelled + with "+" and "-", otherwise they are labelled with "E" and "W". + fmt is a format string to format the meridian labels (default '%g'). + xoffset - label offset from edge of map in x-direction + (default is 0.01 times width of map in map projection coordinates). + yoffset - label offset from edge of map in y-direction + (default is 0.01 times height of map in map projection coordinates). + ax - axes instance (overrides default axes instance) - additional keyword arguments control text properties for labels (see - pylab.text documentation) + additional keyword arguments control text properties for labels (see + pylab.text documentation) """ # get current axes instance (if none specified). if ax is None and self.ax is None: @@ -1824,9 +1748,9 @@ def gcpoints(self,lon1,lat1,lon2,lat2,npoints): """ - compute npoints points along a great circle with endpoints - (lon1,lat1) and (lon2,lat2). Returns arrays x,y - with map projection coordinates. + compute npoints points along a great circle with endpoints + (lon1,lat1) and (lon2,lat2). Returns arrays x,y + with map projection coordinates. """ gc = pyproj.Geod(a=self.rmajor,b=self.rminor) lonlats = gc.npts(lon1,lat1,lon2,lat2,npoints-2) @@ -1839,17 +1763,17 @@ def drawgreatcircle(self,lon1,lat1,lon2,lat2,del_s=100.,**kwargs): """ - draw a great circle on the map. + draw a great circle on the map. - lon1,lat1 - longitude,latitude of one endpoint of the great circle. - lon2,lat2 - longitude,latitude of the other endpoint of the great circle. - del_s - points on great circle computed every delta kilometers (default 100). + lon1,lat1 - longitude,latitude of one endpoint of the great circle. + lon2,lat2 - longitude,latitude of the other endpoint of the great circle. + del_s - points on great circle computed every delta kilometers (default 100). - Other keyword arguments (**kwargs) control plotting of great circle line, - see pylab.plot documentation for details. + Other keyword arguments (**kwargs) control plotting of great circle line, + see pylab.plot documentation for details. - Note: cannot handle situations in which the great circle intersects - the edge of the map projection domain, and then re-enters the domain. + Note: cannot handle situations in which the great circle intersects + the edge of the map projection domain, and then re-enters the domain. """ # use great circle formula for a perfect sphere. gc = pyproj.Geod(a=self.rmajor,b=self.rminor) @@ -1866,29 +1790,29 @@ def transform_scalar(self,datin,lons,lats,nx,ny,returnxy=False,checkbounds=False,order=1,masked=False): """ - interpolate a scalar field (datin) from a lat/lon grid with longitudes = - lons and latitudes = lats to a (ny,nx) native map projection grid. - Typically used to transform data to map projection coordinates - so it can be plotted on the map with imshow. + interpolate a scalar field (datin) from a lat/lon grid with longitudes = + lons and latitudes = lats to a (ny,nx) native map projection grid. + Typically used to transform data to map projection coordinates + so it can be plotted on the map with imshow. - lons, lats must be rank-1 arrays containing longitudes and latitudes - (in degrees) of datin grid in increasing order - (i.e. from dateline eastward, and South Pole northward). - For non-cylindrical projections (those other than - cylindrical equidistant, mercator and miller) - lons must fit within range -180 to 180. + lons, lats must be rank-1 arrays containing longitudes and latitudes + (in degrees) of datin grid in increasing order + (i.e. from dateline eastward, and South Pole northward). + For non-cylindrical projections (those other than + cylindrical equidistant, mercator and miller) + lons must fit within range -180 to 180. - if returnxy=True, the x and y values of the native map projection grid - are also returned. + if returnxy=True, the x and y values of the native map projection grid + are also returned. - If checkbounds=True, values of lons and lats are checked to see that - they lie within the map projection region. Default is False. - If checkbounds=False, points outside map projection region will - be clipped to values on the boundary if masked=False. If masked=True, - the return value will be a masked array with those points masked. + If checkbounds=True, values of lons and lats are checked to see that + they lie within the map projection region. Default is False. + If checkbounds=False, points outside map projection region will + be clipped to values on the boundary if masked=False. If masked=True, + the return value will be a masked array with those points masked. - The order keyword can be 0 for nearest-neighbor interpolation, - or 1 for bilinear interpolation (default 1). + The order keyword can be 0 for nearest-neighbor interpolation, + or 1 for bilinear interpolation (default 1). """ # check that lons, lats increasing delon = lons[1:]-lons[0:-1] @@ -1916,33 +1840,33 @@ def transform_vector(self,uin,vin,lons,lats,nx,ny,returnxy=False,checkbounds=False,order=1,masked=False):... [truncated message content] |
From: <js...@us...> - 2007-11-18 13:32:30
|
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,ucrnrlon,urcrnrlat) in degrees or width and height in meters' else: @@ -493,7 +493,7 @@ raise ValueError, 'must specify lat_0 and lon_0 for Orthographic basemap' if width is not None or height is not None: print 'warning: width and height keywords ignored for %s projection' % self.projection - if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]: + if not using_corners: llcrnrlon = -180. llcrnrlat = -90. urcrnrlon = 180 @@ -511,7 +511,7 @@ raise ValueError, 'must specify lon_0 and satellite_height for Geostationary basemap' if width is not None or height is not None: print 'warning: width and height keywords ignored for %s projection' % self.projection - if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]: + if not using_corners: llcrnrlon = -180. llcrnrlat = -90. urcrnrlon = 180 @@ -539,12 +539,12 @@ projparams['lon_1'] = lon_1 projparams['lat_2'] = lat_2 projparams['lon_2'] = lon_2 - if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]: + if not using_corners: raise ValueError, 'cannot specify map region with width and height keywords for this projection, please specify lat/lon values of corners' elif projection == 'aeqd': if lat_0 is None or lon_0 is None: raise ValueError, 'must specify lat_0 and lon_0 for Azimuthal Equidistant 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: @@ -554,7 +554,7 @@ self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat elif projection == 'mill': - if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]: + if not using_corners: llcrnrlon = -180. llcrnrlat = -90. urcrnrlon = 180 @@ -564,7 +564,7 @@ if width is not None or height is not None: print 'warning: width and height keywords ignored for %s projection' % self.projection elif projection == 'cyl': - if None in [llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat]: + if not using_corners: llcrnrlon = -180. llcrnrlat = -90. urcrnrlon = 180 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-17 22:11:36
|
Revision: 4369 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4369&view=rev Author: jswhit Date: 2007-11-17 14:11:19 -0800 (Sat, 17 Nov 2007) Log Message: ----------- docstring edits Modified Paths: -------------- trunk/toolkits/basemap-testing/examples/setwh.py Modified: trunk/toolkits/basemap-testing/examples/setwh.py =================================================================== --- trunk/toolkits/basemap-testing/examples/setwh.py 2007-11-17 22:10:30 UTC (rev 4368) +++ trunk/toolkits/basemap-testing/examples/setwh.py 2007-11-17 22:11:19 UTC (rev 4369) @@ -4,7 +4,7 @@ from matplotlib.toolkits.basemap import Basemap from pylab import arange, show, title, figure -# setup projection centered on lon_0,lat_0 +# setup projection parameters lat_0 = 40. lon_0 = -100. width = 6000000. @@ -24,7 +24,6 @@ lat_0=lat_0,lon_0=lon_0) npanel = npanel + 1 fig.add_subplot(3,2,npanel) - # setup figure with same aspect ratio as map. m.drawcoastlines() m.drawcountries() m.fillcontinents() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-17 22:10:44
|
Revision: 4368 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4368&view=rev Author: jswhit Date: 2007-11-17 14:10:30 -0800 (Sat, 17 Nov 2007) Log Message: ----------- remove omerc example Modified Paths: -------------- trunk/toolkits/basemap-testing/examples/setwh.py Modified: trunk/toolkits/basemap-testing/examples/setwh.py =================================================================== --- trunk/toolkits/basemap-testing/examples/setwh.py 2007-11-17 19:51:23 UTC (rev 4367) +++ trunk/toolkits/basemap-testing/examples/setwh.py 2007-11-17 22:10:30 UTC (rev 4368) @@ -33,49 +33,4 @@ m.drawmeridians(meridians) title('proj = '+proj+' centered on %sW, %sN' % (lon_0,lat_0),fontsize=10) -proj = 'omerc' -delat = 10. -circles = arange(0.,90.+delat,delat).tolist()+\ - arange(-delat,-90.-delat,-delat).tolist() -delon = 10. -meridians = arange(10.,360.,delon) -lat_1 = 40; lat_2 = 55 -lon_1 = -120; lon_2 = -140 -lat_0 = 47.5 ; lon_0 = -130 -fig = figure() -width = 1500000. -height = 2.5*width -m = Basemap(width=width,height=height, - resolution='l',projection=proj,\ - lon_1=lon_1,lon_2=lon_2,\ - lat_1=lat_1,lat_2=lat_2,\ - lat_0=lat_0,lon_0=lon_0) -m.drawcoastlines(linewidth=0.5) -m.drawcountries(linewidth=0.5) -m.fillcontinents() -m.drawstates(linewidth=0.5) -m.drawparallels(circles) -m.drawmeridians(meridians) -title('proj = '+proj+' centered on %sW, %sN' % (lon_0,lat_0),fontsize=10) - - -#lon_0 = -8 -#lat_0 = 53.3 -#width=350000. -#height= 1.33*width -#fig=figure() -#proj='tmerc' -#circles = arange(50,60,1) -#meridians = arange(-12,2,1) -#m = Basemap(width=width,height=height, -# resolution='i',projection=proj,\ -# lat_0=lat_0,lon_0=lon_0) -#m.drawcoastlines(linewidth=0.5) -#m.drawcountries(linewidth=0.5) -#m.fillcontinents() -#m.drawstates(linewidth=0.5) -#m.drawparallels(circles) -#m.drawmeridians(meridians) -#title('proj = '+proj+' centered on %sW, %sN' % (lon_0,lat_0),fontsize=10) - show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-17 19:51:24
|
Revision: 4367 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4367&view=rev Author: jswhit Date: 2007-11-17 11:51:23 -0800 (Sat, 17 Nov 2007) Log Message: ----------- wasn't installing data files Modified Paths: -------------- trunk/toolkits/basemap-testing/setup-data.py Modified: trunk/toolkits/basemap-testing/setup-data.py =================================================================== --- trunk/toolkits/basemap-testing/setup-data.py 2007-11-17 18:54:40 UTC (rev 4366) +++ trunk/toolkits/basemap-testing/setup-data.py 2007-11-17 19:51:23 UTC (rev 4367) @@ -11,7 +11,7 @@ packages = ['matplotlib.toolkits.basemap.data'] package_dirs = {'':'lib'} boundaryfiles = glob.glob("lib/matplotlib/toolkits/basemap/data/*_f.dat") -basemap_datafiles = [os.path.join('data',os.path.basename(bfile)) for bfile in boundaryfiles] +basemap_datafiles = [os.path.basename(bfile) for bfile in boundaryfiles] package_data = {'matplotlib.toolkits.basemap.data':basemap_datafiles} setup( name = "basemap-data-fullres", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-17 18:54:41
|
Revision: 4366 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4366&view=rev Author: jswhit Date: 2007-11-17 10:54:40 -0800 (Sat, 17 Nov 2007) Log Message: ----------- update full-res data install instructions. Modified Paths: -------------- trunk/toolkits/basemap-testing/README Modified: trunk/toolkits/basemap-testing/README =================================================================== --- trunk/toolkits/basemap-testing/README 2007-11-17 18:49:55 UTC (rev 4365) +++ trunk/toolkits/basemap-testing/README 2007-11-17 18:54:40 UTC (rev 4366) @@ -86,7 +86,8 @@ 4) if you want the full-resolution coastlines, download basemap-data-fullres-X.Y.Z.tar.gz (about 70 mb), untar -it in the top level basemap directory and run setup.py install again. +it, cd into basemap-data-fullres-X.Y.Z and +run 'python setup-data.py install'. **Contact** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-17 18:49:57
|
Revision: 4365 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4365&view=rev Author: jswhit Date: 2007-11-17 10:49:55 -0800 (Sat, 17 Nov 2007) Log Message: ----------- obsolete Removed Paths: ------------- trunk/toolkits/basemap-testing/MANIFEST-data.in Deleted: trunk/toolkits/basemap-testing/MANIFEST-data.in =================================================================== --- trunk/toolkits/basemap-testing/MANIFEST-data.in 2007-11-17 18:49:43 UTC (rev 4364) +++ trunk/toolkits/basemap-testing/MANIFEST-data.in 2007-11-17 18:49:55 UTC (rev 4365) @@ -1,12 +0,0 @@ -include MANIFEST-data.in -include README -include setup-data.py -include lib/matplotlib/toolkits/basemap/data/__init__.py -include lib/matplotlib/toolkits/basemap/data/countries_f.dat -include lib/matplotlib/toolkits/basemap/data/countriesmeta_f.dat -include lib/matplotlib/toolkits/basemap/data/gshhs_f.dat -include lib/matplotlib/toolkits/basemap/data/gshhsmeta_f.dat -include lib/matplotlib/toolkits/basemap/data/rivers_f.dat -include lib/matplotlib/toolkits/basemap/data/riversmeta_f.dat -include lib/matplotlib/toolkits/basemap/data/states_f.dat -include lib/matplotlib/toolkits/basemap/data/statesmeta_f.dat This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-17 18:49:49
|
Revision: 4364 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4364&view=rev Author: jswhit Date: 2007-11-17 10:49:43 -0800 (Sat, 17 Nov 2007) Log Message: ----------- new file Added Paths: ----------- trunk/toolkits/basemap-testing/MANIFEST-data Added: trunk/toolkits/basemap-testing/MANIFEST-data =================================================================== --- trunk/toolkits/basemap-testing/MANIFEST-data (rev 0) +++ trunk/toolkits/basemap-testing/MANIFEST-data 2007-11-17 18:49:43 UTC (rev 4364) @@ -0,0 +1,13 @@ +MANIFEST-data +LICENSE_data +README +setup-data.py +lib/matplotlib/toolkits/basemap/data/__init__.py +lib/matplotlib/toolkits/basemap/data/countries_f.dat +lib/matplotlib/toolkits/basemap/data/countriesmeta_f.dat +lib/matplotlib/toolkits/basemap/data/gshhs_f.dat +lib/matplotlib/toolkits/basemap/data/gshhsmeta_f.dat +lib/matplotlib/toolkits/basemap/data/rivers_f.dat +lib/matplotlib/toolkits/basemap/data/riversmeta_f.dat +lib/matplotlib/toolkits/basemap/data/states_f.dat +lib/matplotlib/toolkits/basemap/data/statesmeta_f.dat This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-17 18:27:30
|
Revision: 4363 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4363&view=rev Author: jswhit Date: 2007-11-17 10:27:29 -0800 (Sat, 17 Nov 2007) Log Message: ----------- stuff for basemap-data-fullres package Modified Paths: -------------- trunk/toolkits/basemap-testing/setup-data.py Added Paths: ----------- trunk/toolkits/basemap-testing/MANIFEST-data.in trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/data/__init__.py Added: trunk/toolkits/basemap-testing/MANIFEST-data.in =================================================================== --- trunk/toolkits/basemap-testing/MANIFEST-data.in (rev 0) +++ trunk/toolkits/basemap-testing/MANIFEST-data.in 2007-11-17 18:27:29 UTC (rev 4363) @@ -0,0 +1,12 @@ +include MANIFEST-data.in +include README +include setup-data.py +include lib/matplotlib/toolkits/basemap/data/__init__.py +include lib/matplotlib/toolkits/basemap/data/countries_f.dat +include lib/matplotlib/toolkits/basemap/data/countriesmeta_f.dat +include lib/matplotlib/toolkits/basemap/data/gshhs_f.dat +include lib/matplotlib/toolkits/basemap/data/gshhsmeta_f.dat +include lib/matplotlib/toolkits/basemap/data/rivers_f.dat +include lib/matplotlib/toolkits/basemap/data/riversmeta_f.dat +include lib/matplotlib/toolkits/basemap/data/states_f.dat +include lib/matplotlib/toolkits/basemap/data/statesmeta_f.dat Added: trunk/toolkits/basemap-testing/lib/matplotlib/toolkits/basemap/data/__init__.py =================================================================== Modified: trunk/toolkits/basemap-testing/setup-data.py =================================================================== --- trunk/toolkits/basemap-testing/setup-data.py 2007-11-17 18:11:07 UTC (rev 4362) +++ trunk/toolkits/basemap-testing/setup-data.py 2007-11-17 18:27:29 UTC (rev 4363) @@ -8,12 +8,11 @@ else: additional_params = {} from distutils.core import setup -packages = ['matplotlib.toolkits.basemap'] +packages = ['matplotlib.toolkits.basemap.data'] package_dirs = {'':'lib'} boundaryfiles = glob.glob("lib/matplotlib/toolkits/basemap/data/*_f.dat") basemap_datafiles = [os.path.join('data',os.path.basename(bfile)) for bfile in boundaryfiles] -package_data = {'matplotlib.toolkits.basemap':basemap_datafiles} -print package_data +package_data = {'matplotlib.toolkits.basemap.data':basemap_datafiles} setup( name = "basemap-data-fullres", version = "0.9.7", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-17 18:11:13
|
Revision: 4362 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4362&view=rev Author: jswhit Date: 2007-11-17 10:11:07 -0800 (Sat, 17 Nov 2007) Log Message: ----------- setup.py file for full-res data. Added Paths: ----------- trunk/toolkits/basemap-testing/setup-data.py Added: trunk/toolkits/basemap-testing/setup-data.py =================================================================== --- trunk/toolkits/basemap-testing/setup-data.py (rev 0) +++ trunk/toolkits/basemap-testing/setup-data.py 2007-11-17 18:11:07 UTC (rev 4362) @@ -0,0 +1,37 @@ +import sys, glob, os +if 'setuptools' in sys.modules: +# Are we running with setuptools? +# if so, need to specify all the packages in heirarchy + additional_params = {'namespace_packages' : ['matplotlib.toolkits']} + packages.extend(['matplotlib', 'matplotlib.toolkits']) + setup = setuptools.setup +else: + additional_params = {} + from distutils.core import setup +packages = ['matplotlib.toolkits.basemap'] +package_dirs = {'':'lib'} +boundaryfiles = glob.glob("lib/matplotlib/toolkits/basemap/data/*_f.dat") +basemap_datafiles = [os.path.join('data',os.path.basename(bfile)) for bfile in boundaryfiles] +package_data = {'matplotlib.toolkits.basemap':basemap_datafiles} +print package_data +setup( + name = "basemap-data-fullres", + version = "0.9.7", + description = "full-resolution boundary data for basemap", + url = "http://matplotlib.sourceforge.net/toolkits.html", + download_url = "http://sourceforge.net/projects/matplotlib", + author = "Jeff Whitaker", + author_email = "jef...@no...", + platforms = ["any"], + license = "OSI Approved", + keywords = ["python","plotting","plots","graphs","charts","GIS","mapping","map projections","maps"], + classifiers = ["Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "License :: OSI Approved", + "Topic :: Scientific/Engineering :: Visualization", + "Topic :: Software Development :: Libraries :: Python Modules", + "Operating System :: OS Independent"], + packages = packages, + package_dir = package_dirs, + package_data = package_data + ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |