From: <js...@us...> - 2009-11-04 20:22:45
|
Revision: 7938 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7938&view=rev Author: jswhit Date: 2009-11-04 20:22:35 +0000 (Wed, 04 Nov 2009) Log Message: ----------- don't try to create _geoslib Polygon instances if resolution=None Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-11-04 17:53:25 UTC (rev 7937) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-11-04 20:22:35 UTC (rev 7938) @@ -805,15 +805,16 @@ # currently only used in is_land method. self.landpolygons=[] self.lakepolygons=[] - #self.islandinlakepolygons=[] - #self.lakeinislandinlakepolygons=[] - x, y = zip(*self.coastpolygons) - for x,y,type in zip(x,y,self.coastpolygontypes): - b = np.asarray([x,y]).T - if type == 1: self.landpolygons.append(_geoslib.Polygon(b)) - if type == 2: self.lakepolygons.append(_geoslib.Polygon(b)) - #if type == 3: self.islandinlakepolygons.append(_geoslib.Polygon(b)) - #if type == 4: self.lakeinislandinlakepolygons.append(_geoslib.Polygon(b)) + if resolution is not None: + #self.islandinlakepolygons=[] + #self.lakeinislandinlakepolygons=[] + x, y = zip(*self.coastpolygons) + for x,y,type in zip(x,y,self.coastpolygontypes): + b = np.asarray([x,y]).T + if type == 1: self.landpolygons.append(_geoslib.Polygon(b)) + if type == 2: self.lakepolygons.append(_geoslib.Polygon(b)) + #if type == 3: self.islandinlakepolygons.append(_geoslib.Polygon(b)) + #if type == 4: self.lakeinislandinlakepolygons.append(_geoslib.Polygon(b)) # set __init__'s docstring __init__.__doc__ = _Basemap_init_doc @@ -1558,6 +1559,7 @@ the GSHHS coastline polygons associated with the class instance. Points over lakes inside land regions are not counted as land points. """ + if resolution is None: return None landpt = False for poly in self.landpolygons: landpt = _geoslib.Point((xpt,ypt)).within(poly) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2009-12-08 02:12:46
|
Revision: 8013 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8013&view=rev Author: efiring Date: 2009-12-08 02:12:38 +0000 (Tue, 08 Dec 2009) Log Message: ----------- bugfix: skip trying to make geos polygon lists if no coast polygons are found Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-08 02:02:49 UTC (rev 8012) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-08 02:12:38 UTC (rev 8013) @@ -805,7 +805,7 @@ # currently only used in is_land method. self.landpolygons=[] self.lakepolygons=[] - if resolution is not None: + if resolution is not None and len(self.coastpolygons) > 0: #self.islandinlakepolygons=[] #self.lakeinislandinlakepolygons=[] x, y = zip(*self.coastpolygons) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2009-12-12 14:18:38
|
Revision: 8024 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8024&view=rev Author: jswhit Date: 2009-12-12 14:18:30 +0000 (Sat, 12 Dec 2009) Log Message: ----------- fix ambiguity in lonmin, lonmax when projection crosses dateline. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-11 16:57:53 UTC (rev 8023) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-12 14:18:30 UTC (rev 8024) @@ -750,6 +750,11 @@ self.latmax = lats.max() self.lonmin = lons.min() self.lonmax = lons.max() + # projection crosses dateline. + if self.lonmin < 0 and self.lonmax > 0.: + lons = np.where(lons < 0, lons+360, lons) + self.lonmin = lons.min() + self.lonmax = lons.max() # if ax == None, pyplot.gca may be used. self.ax = ax This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2009-12-12 18:25:04
|
Revision: 8025 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8025&view=rev Author: jswhit Date: 2009-12-12 18:24:54 +0000 (Sat, 12 Dec 2009) Log Message: ----------- more fixes for computation of lonmin, lonmax Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-12 14:18:30 UTC (rev 8024) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-12-12 18:24:54 UTC (rev 8025) @@ -733,28 +733,6 @@ self.llcrnry = proj.llcrnry self.urcrnrx = proj.urcrnrx self.urcrnry = proj.urcrnry - # set min/max lats for projection domain. - if projection in _cylproj: - self.latmin = self.llcrnrlat - self.latmax = self.urcrnrlat - self.lonmin = self.llcrnrlon - self.lonmax = self.urcrnrlon - elif projection in ['ortho','geos'] + _pseudocyl: - self.latmin = -90. - self.latmax = 90. - self.lonmin = self.llcrnrlon - self.lonmax = self.urcrnrlon - else: - lons, lats = self.makegrid(1001,1001) - self.latmin = lats.min() - self.latmax = lats.max() - self.lonmin = lons.min() - self.lonmax = lons.max() - # projection crosses dateline. - if self.lonmin < 0 and self.lonmax > 0.: - lons = np.where(lons < 0, lons+360, lons) - self.lonmin = lons.min() - self.lonmax = lons.max() # if ax == None, pyplot.gca may be used. self.ax = ax @@ -778,6 +756,38 @@ self.area_thresh = area_thresh # define map boundary polygon (in lat/lon coordinates) self._boundarypolyll, self._boundarypolyxy = self._getmapboundary() + # set min/max lats for projection domain. + if self.projection in _cylproj: + self.latmin = self.llcrnrlat + self.latmax = self.urcrnrlat + self.lonmin = self.llcrnrlon + self.lonmax = self.urcrnrlon + elif self.projection in ['ortho','geos'] + _pseudocyl: + self.latmin = -90. + self.latmax = 90. + self.lonmin = self.llcrnrlon + self.lonmax = self.urcrnrlon + else: + lons, lats = self.makegrid(1001,1001) + self.latmin = lats.min() + self.latmax = lats.max() + self.lonmin = lons.min() + self.lonmax = lons.max() + NPole = _geoslib.Point(self(0.,90.)) + SPole = _geoslib.Point(self(0.,-90.)) + Dateline = _geoslib.Point(self(180.,lat_0)) + Greenwich = _geoslib.Point(self(0.,lat_0)) + hasNP = NPole.within(self._boundarypolyxy) + hasSP = SPole.within(self._boundarypolyxy) + hasPole = hasNP or hasSP + hasDateline = Dateline.within(self._boundarypolyxy) + hasGreenwich = Greenwich.within(self._boundarypolyxy) + # projection crosses dateline (and not Greenwich or pole). + if not hasPole and hasDateline and not hasGreenwich: + if self.lonmin < 0 and self.lonmax > 0.: + lons = np.where(lons < 0, lons+360, lons) + self.lonmin = lons.min() + self.lonmax = lons.max() # read in coastline polygons, only keeping those that # intersect map boundary polygon. if self.resolution is not None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-01-11 12:38:51
|
Revision: 8075 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8075&view=rev Author: jswhit Date: 2010-01-11 12:28:15 +0000 (Mon, 11 Jan 2010) Log Message: ----------- infer lat_0 from ymin,ymax if necessary Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-01-04 22:58:43 UTC (rev 8074) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-01-11 12:28:15 UTC (rev 8075) @@ -775,6 +775,10 @@ self.lonmax = lons.max() NPole = _geoslib.Point(self(0.,90.)) SPole = _geoslib.Point(self(0.,-90.)) + if lat_0 is None: + lon_0, lat_0 =\ + self(0.5*(self.xmin+self.xmax), + 0.5*(self.ymin+self.ymax),inverse=True) Dateline = _geoslib.Point(self(180.,lat_0)) Greenwich = _geoslib.Point(self(0.,lat_0)) hasNP = NPole.within(self._boundarypolyxy) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-01-25 13:04:28
|
Revision: 8096 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8096&view=rev Author: jswhit Date: 2010-01-25 13:04:22 +0000 (Mon, 25 Jan 2010) Log Message: ----------- add more informative error message when lat_0 is nonzero for projection='geos' Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-01-22 23:48:35 UTC (rev 8095) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-01-25 13:04:22 UTC (rev 8096) @@ -585,6 +585,8 @@ if np.abs(lat_0) < 1.e-2: lat_0 = 1.e-2 projparams['lat_0'] = lat_0 elif projection == 'geos': + if lat_0 is not None and lat_0 != 0: + raise ValueError, 'lat_0 must be zero for Geostationary basemap' if lon_0 is None: raise ValueError, 'must specify lon_0 for Geostationary basemap' if width is not None or height is not None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-02-25 15:54:31
|
Revision: 8155 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8155&view=rev Author: jswhit Date: 2010-02-25 15:54:08 +0000 (Thu, 25 Feb 2010) Log Message: ----------- fix typo in previous commit Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-02-25 15:53:30 UTC (rev 8154) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-02-25 15:54:08 UTC (rev 8155) @@ -3753,7 +3753,7 @@ except ImportError: raise ValueError('scipy.ndimage must be installed if order=3') coords = [ycoords,xcoords] - map_coordinates(datain,coords,order=3,mode='constant') + dataout = map_coordinates(datain,coords,order=3,mode='constant') else: raise ValueError,'order keyword must be 0, 1 or 3' if masked and isinstance(masked,bool): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-02-25 15:57:21
|
Revision: 8156 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8156&view=rev Author: jswhit Date: 2010-02-25 15:57:15 +0000 (Thu, 25 Feb 2010) Log Message: ----------- update transform_scalar and transform_vector docstrings. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-02-25 15:54:08 UTC (rev 8155) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-02-25 15:57:15 UTC (rev 8156) @@ -2384,7 +2384,8 @@ array with values outside map projection region masked (Default False). order 0 for nearest-neighbor interpolation, 1 for - bilinear (Default 1). + bilinear, 3 for cubic spline (Default 1). + Cubic spline interpolation requires scipy.ndimage. ============== ==================================================== Returns ``datout`` (data on map projection grid). @@ -2455,7 +2456,8 @@ array with values outside map projection region masked (Default False). order 0 for nearest-neighbor interpolation, 1 for - bilinear (Default 1). + bilinear, 3 for cubic spline (Default 1). + Cubic spline interpolation requires scipy.ndimage. ============== ==================================================== Returns ``uout, vout`` (vector field on map projection grid). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-02-26 16:04:57
|
Revision: 8159 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8159&view=rev Author: jswhit Date: 2010-02-26 16:04:49 +0000 (Fri, 26 Feb 2010) Log Message: ----------- make default behaviour for order=3 match orders=0,1 for grid pts outside range of data. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-02-26 00:28:14 UTC (rev 8158) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-02-26 16:04:49 UTC (rev 8159) @@ -3755,7 +3755,7 @@ except ImportError: raise ValueError('scipy.ndimage must be installed if order=3') coords = [ycoords,xcoords] - dataout = map_coordinates(datain,coords,order=3,mode='constant') + dataout = map_coordinates(datain,coords,order=3,mode='nearest') else: raise ValueError,'order keyword must be 0, 1 or 3' if masked and isinstance(masked,bool): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-04-21 20:24:33
|
Revision: 8261 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8261&view=rev Author: efiring Date: 2010-04-21 20:24:27 +0000 (Wed, 21 Apr 2010) Log Message: ----------- Remove redundant operations, especially forced drawing in interactive mode Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-04-20 22:37:01 UTC (rev 8260) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-04-21 20:24:27 UTC (rev 8261) @@ -30,7 +30,7 @@ higher, you have version %s""" % (_mpl_required_version,_matplotlib_version)) raise ImportError(msg) -from matplotlib import rcParams, is_interactive, _pylab_helpers +from matplotlib import rcParams, is_interactive from matplotlib.collections import LineCollection from matplotlib.patches import Ellipse, Circle, Polygon from matplotlib.lines import Line2D @@ -41,7 +41,6 @@ import numpy.ma as ma from shapelib import ShapeFile import _geoslib, netcdftime -import cm # basemap data files now installed in lib/matplotlib/toolkits/basemap/data # check to see if environment variable BASEMAPDATA set to a directory, @@ -313,7 +312,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 + only relevant for geostationary and near-sided perspective (``geos`` or ``nsper``) projections. Default 35,786 km. ================ ==================================================== @@ -760,6 +759,8 @@ # if ax == None, pyplot.gca may be used. self.ax = ax self.lsmask = None + # This will record hashs of Axes instances. + self._initialized_axes = set() # set defaults for area_thresh. self.resolution = resolution @@ -2583,11 +2584,33 @@ def set_axes_limits(self,ax=None): """ + Final step in Basemap method wrappers of Axes plotting methods: + Set axis limits, fix aspect ratio for map domain using current - or specified axes instance. + or specified axes instance. This is done only once per axes + instance. + + In interactive mode, this method always calls draw_if_interactive + before returning. + """ # get current axes instance (if none specified). ax = ax or self._check_ax() + + # If we have already set the axes limits, and if the user + # has not defeated this by turning autoscaling back on, + # then all we need to do is plot if interactive. + if (hash(ax) in self._initialized_axes + and not ax.get_autoscalex_on() + and not ax.get_autoscaley_on()): + if is_interactive(): + import matplotlib.pyplot as plt + plt.draw_if_interactive() + return + + self._initialized_axes.add(hash(ax)) + # Take control of axis scaling: + ax.set_autoscale_on(False) # update data limits for map domain. corners = ((self.llcrnrx,self.llcrnry), (self.urcrnrx,self.urcrnry)) ax.update_datalim( corners ) @@ -2605,15 +2628,14 @@ ax.set_aspect('equal',adjustable='box',anchor=self.anchor) else: ax.set_aspect('auto',adjustable='box',anchor=self.anchor) - ax.apply_aspect() # make sure axis ticks are turned off. if self.noticks: ax.set_xticks([]) ax.set_yticks([]) # force draw if in interactive mode. if is_interactive(): - figManager = _pylab_helpers.Gcf.get_active() - figManager.canvas.draw() + import matplotlib.pyplot as plt + plt.draw_if_interactive() def scatter(self, *args, **kwargs): """ @@ -2624,10 +2646,7 @@ Other \**kwargs passed on to matplotlib.pyplot.scatter. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # allow callers to override the hold state by passing hold=True|False b = ax.ishold() h = kwargs.pop('hold',None) @@ -2635,22 +2654,16 @@ ax.hold(h) try: ret = ax.scatter(*args, **kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) # reset current active image (only if pyplot is imported). - try: + if plt: try: plt.sci(ret) except AttributeError: plt.gci._current = ret - except: - pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2672,10 +2685,6 @@ ax.hold(h) try: ret = ax.plot(*args, **kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise @@ -2698,10 +2707,7 @@ returns an matplotlib.image.AxesImage instance. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) kwargs['extent']=(self.llcrnrx,self.urcrnrx,self.llcrnry,self.urcrnry) # use origin='lower', unless overridden. if not kwargs.has_key('origin'): @@ -2713,22 +2719,16 @@ ax.hold(h) try: ret = ax.imshow(*args, **kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) # reset current active image (only if pyplot is imported). - try: + if plt: try: plt.sci(ret) except AttributeError: plt.gci._current = ret - except: - pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2746,10 +2746,7 @@ Other \**kwargs passed on to matplotlib.pyplot.pcolor. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # make x,y masked arrays # (masked where data is outside of projection limb) x = ma.masked_values(np.where(x > 1.e20,1.e20,x), 1.e20) @@ -2761,22 +2758,16 @@ ax.hold(h) try: ret = ax.pcolor(x,y,data,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) # reset current active image (only if pyplot is imported). - try: + if plt: try: plt.sci(ret) except AttributeError: plt.gci._current = ret - except: - pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2790,10 +2781,7 @@ Other \**kwargs passed on to matplotlib.pyplot.pcolormesh. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # allow callers to override the hold state by passing hold=True|False b = ax.ishold() h = kwargs.pop('hold',None) @@ -2801,22 +2789,16 @@ ax.hold(h) try: ret = ax.pcolormesh(x,y,data,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) # reset current active image (only if pyplot is imported). - try: + if plt: try: plt.sci(ret) except AttributeError: plt.gci._current = ret - except: - pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2830,10 +2812,7 @@ Other \*args and \**kwargs passed on to matplotlib.pyplot.contour. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # make sure x is monotonically increasing - if not, # print warning suggesting that the data be shifted in longitude # with the shiftgrid function. @@ -2865,10 +2844,6 @@ ax.hold(h) try: CS = ax.contour(x,y,data,*args,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise @@ -2876,7 +2851,7 @@ # set axes limits to fit map region. self.set_axes_limits(ax=ax) # reset current active image (only if pyplot is imported). - try: + if plt: try: # new contour. if CS._A is not None: try: @@ -2889,8 +2864,6 @@ plt.sci(CS[1].mappable) except AttributeError: plt.gci._current = CS[1].mappable - except: - pass return CS def contourf(self,x,y,data,*args,**kwargs): @@ -2905,10 +2878,7 @@ Other \*args and \**kwargs passed on to matplotlib.pyplot.scatter. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # make sure x is monotonically increasing - if not, # print warning suggesting that the data be shifted in longitude # with the shiftgrid function. @@ -2948,10 +2918,6 @@ ax.hold(h) try: CS = ax.contourf(x,y,data,*args,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise @@ -2959,7 +2925,7 @@ # set axes limits to fit map region. self.set_axes_limits(ax=ax) # reset current active image (only if pyplot is imported). - try: + if plt: try: # new contour. if CS._A is not None: try: @@ -2972,8 +2938,6 @@ plt.sci(CS[1].mappable) except AttributeError: plt.gci._current = CS[1].mappable - except: - pass return CS def quiver(self, x, y, u, v, *args, **kwargs): @@ -2985,10 +2949,7 @@ Other \*args and \**kwargs passed on to matplotlib.pyplot.quiver. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # allow callers to override the hold state by passing hold=True|False b = ax.ishold() h = kwargs.pop('hold',None) @@ -2996,14 +2957,12 @@ ax.hold(h) try: ret = ax.quiver(x,y,u,v,*args,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) + if plt is not None and ret.get_array() is not None: + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -3025,10 +2984,7 @@ barb method requires matplotlib 0.98.3 or higher, you have %s""" % _matplotlib_version) raise NotImplementedError(msg) - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # allow callers to override the hold state by passing hold=True|False b = ax.ishold() h = kwargs.pop('hold',None) @@ -3043,14 +2999,14 @@ retnh = ax.barbs(x,y,unh,vnh,*args,**kwargs) kwargs['flip_barb']=True retsh = ax.barbs(x,y,ush,vsh,*args,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) + # Because there are two collections returned in general, + # we can't set the current image... + #if plt is not None and ret.get_array() is not None: + # plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return retnh,retsh @@ -3595,6 +3551,24 @@ ax = self.ax return ax + def _ax_plt_from_kw(self, kw): + """ + Return (ax, plt), where ax is the current axes, and plt is + None or a reference to the pyplot module. + + plt will be None if ax was popped from kw or taken from self.ax; + otherwise, pyplot was used and is returned. + """ + plt = None + _ax = kw.pop('ax', None) + if _ax is None: + _ax = self.ax + if _ax is None: + import matplotlib.pyplot as plt + _ax = plt.gca() + return _ax, plt + + ### End of Basemap class def _searchlist(a,x): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-04-21 21:47:20
|
Revision: 8262 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8262&view=rev Author: efiring Date: 2010-04-21 21:47:13 +0000 (Wed, 21 Apr 2010) Log Message: ----------- Remove some pre-mpl-0.98 support Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-04-21 20:24:27 UTC (rev 8261) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-04-21 21:47:13 UTC (rev 8262) @@ -2660,10 +2660,7 @@ ax.hold(b) # reset current active image (only if pyplot is imported). if plt: - try: - plt.sci(ret) - except AttributeError: - plt.gci._current = ret + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2725,10 +2722,7 @@ ax.hold(b) # reset current active image (only if pyplot is imported). if plt: - try: - plt.sci(ret) - except AttributeError: - plt.gci._current = ret + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2764,10 +2758,7 @@ ax.hold(b) # reset current active image (only if pyplot is imported). if plt: - try: - plt.sci(ret) - except AttributeError: - plt.gci._current = ret + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2795,10 +2786,7 @@ ax.hold(b) # reset current active image (only if pyplot is imported). if plt: - try: - plt.sci(ret) - except AttributeError: - plt.gci._current = ret + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2848,22 +2836,11 @@ ax.hold(b) raise ax.hold(b) + # reset current active image (only if pyplot is imported). + if plt and CS.get_array() is not None: + plt.sci(CS) # set axes limits to fit map region. self.set_axes_limits(ax=ax) - # reset current active image (only if pyplot is imported). - if plt: - try: # new contour. - if CS._A is not None: - try: - plt.sci(CS) - except AttributeError: - plt.gci._current = CS - except: # old contour. - if CS[1].mappable is not None: - try: - plt.sci(CS[1].mappable) - except AttributeError: - plt.gci._current = CS[1].mappable return CS def contourf(self,x,y,data,*args,**kwargs): @@ -2922,22 +2899,11 @@ ax.hold(b) raise ax.hold(b) + # reset current active image (only if pyplot is imported). + if plt and CS.get_array() is not None: + plt.sci(CS) # set axes limits to fit map region. self.set_axes_limits(ax=ax) - # reset current active image (only if pyplot is imported). - if plt: - try: # new contour. - if CS._A is not None: - try: - plt.sci(CS) - except AttributeError: - plt.gci._current = CS - except: # old contour. - if CS[1].mappable is not None: - try: - plt.sci(CS[1].mappable) - except AttributeError: - plt.gci._current = CS[1].mappable return CS def quiver(self, x, y, u, v, *args, **kwargs): @@ -3006,7 +2972,7 @@ # Because there are two collections returned in general, # we can't set the current image... #if plt is not None and ret.get_array() is not None: - # plt.sci(ret) + # plt.sci(retnh) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return retnh,retsh This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-05-11 20:00:20
|
Revision: 8307 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8307&view=rev Author: jswhit Date: 2010-05-11 20:00:14 +0000 (Tue, 11 May 2010) Log Message: ----------- fix bug in is_land method. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-05-10 20:34:33 UTC (rev 8306) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-05-11 20:00:14 UTC (rev 8307) @@ -1603,7 +1603,7 @@ the GSHHS coastline polygons associated with the class instance. Points over lakes inside land regions are not counted as land points. """ - if resolution is None: return None + if self.resolution is None: return None landpt = False for poly in self.landpolygons: landpt = _geoslib.Point((xpt,ypt)).within(poly) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-05-12 14:42:05
|
Revision: 8309 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8309&view=rev Author: jswhit Date: 2010-05-12 14:41:58 +0000 (Wed, 12 May 2010) Log Message: ----------- let continents that fill whole map be filled. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-05-11 20:23:04 UTC (rev 8308) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-05-12 14:41:58 UTC (rev 8309) @@ -1411,19 +1411,22 @@ ya = np.array(y,np.float32) # check to see if all four corners of domain in polygon (if so, # don't draw since it will just fill in the whole map). - delx = 10; dely = 10 - if self.projection in ['cyl']: - delx = 0.1 - dely = 0.1 - test1 = np.fabs(xa-self.urcrnrx) < delx - test2 = np.fabs(xa-self.llcrnrx) < delx - test3 = np.fabs(ya-self.urcrnry) < dely - test4 = np.fabs(ya-self.llcrnry) < dely - hasp1 = np.sum(test1*test3) - hasp2 = np.sum(test2*test3) - hasp4 = np.sum(test2*test4) - hasp3 = np.sum(test1*test4) - if not hasp1 or not hasp2 or not hasp3 or not hasp4: + # ** turn this off for now since it prevents continents that + # fill the whole map from being filled ** + #delx = 10; dely = 10 + #if self.projection in ['cyl']: + # delx = 0.1 + # dely = 0.1 + #test1 = np.fabs(xa-self.urcrnrx) < delx + #test2 = np.fabs(xa-self.llcrnrx) < delx + #test3 = np.fabs(ya-self.urcrnry) < dely + #test4 = np.fabs(ya-self.llcrnry) < dely + #hasp1 = np.sum(test1*test3) + #hasp2 = np.sum(test2*test3) + #hasp4 = np.sum(test2*test4) + #hasp3 = np.sum(test1*test4) + #if not hasp1 or not hasp2 or not hasp3 or not hasp4: + if 1: xy = zip(xa.tolist(),ya.tolist()) if self.coastpolygontypes[npoly] not in [2,4]: poly = Polygon(xy,facecolor=color,edgecolor=color,linewidth=0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-05-27 18:56:25
|
Revision: 8339 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8339&view=rev Author: jswhit Date: 2010-05-27 18:56:19 +0000 (Thu, 27 May 2010) Log Message: ----------- raise ImportError if trying to plot on triangular grids with basemap < 1.0 Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-05-27 12:43:32 UTC (rev 8338) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-05-27 18:56:19 UTC (rev 8339) @@ -2755,6 +2755,11 @@ ax.hold(h) try: if tri: + try: + import matplotlib.tri as tri + except: + msg='need basemap > 0.99.1 to plot on unstructured grids' + Raise ImportError(msg) # for unstructured grids, toss out points outside # projection limb (don't use those points in triangulation). if hasattr(data,'mask'): @@ -2767,7 +2772,6 @@ y = np.compress(mask,y) data = np.compress(mask,data) if masked: - import matplotlib.tri as tri triang = tri.Triangulation(x, y) z = data[triang.triangles] mask = (z > 1.e20).sum(axis=-1) @@ -2841,6 +2845,11 @@ ax.hold(h) try: if kwargs.has_key('tri') and kwargs['tri']: + try: + import matplotlib.tri as tri + except: + msg='need basemap > 0.99.1 to plot on unstructured grids' + Raise ImportError(msg) # for unstructured grids, toss out points outside # projection limb (don't use those points in triangulation). if hasattr(data,'mask'): @@ -2853,7 +2862,6 @@ y = np.compress(mask,y) data = np.compress(mask,data) if masked: - import matplotlib.tri as tri triang = tri.Triangulation(x, y) z = data[triang.triangles] mask = (z > 1.e20).sum(axis=-1) @@ -2922,6 +2930,11 @@ ax.hold(h) try: if kwargs.has_key('tri') and kwargs['tri']: + try: + import matplotlib.tri as tri + except: + msg='need basemap > 0.99.1 to plot on unstructured grids' + Raise ImportError(msg) # for unstructured grids, toss out points outside # projection limb (don't use those points in triangulation). if hasattr(data,'mask'): @@ -2934,7 +2947,6 @@ y = np.compress(mask,y) data = np.compress(mask,data) if masked: - import matplotlib.tri as tri triang = tri.Triangulation(x, y) z = data[triang.triangles] mask = (z > 1.e20).sum(axis=-1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-05-28 18:53:55
|
Revision: 8342 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8342&view=rev Author: jswhit Date: 2010-05-28 18:53:48 +0000 (Fri, 28 May 2010) Log Message: ----------- fix typo Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-05-28 17:42:05 UTC (rev 8341) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-05-28 18:53:48 UTC (rev 8342) @@ -2759,7 +2759,7 @@ import matplotlib.tri as tri except: msg='need basemap > 0.99.1 to plot on unstructured grids' - Raise ImportError(msg) + raise ImportError(msg) # for unstructured grids, toss out points outside # projection limb (don't use those points in triangulation). if hasattr(data,'mask'): @@ -2849,7 +2849,7 @@ import matplotlib.tri as tri except: msg='need basemap > 0.99.1 to plot on unstructured grids' - Raise ImportError(msg) + raise ImportError(msg) # for unstructured grids, toss out points outside # projection limb (don't use those points in triangulation). if hasattr(data,'mask'): @@ -2934,7 +2934,7 @@ import matplotlib.tri as tri except: msg='need basemap > 0.99.1 to plot on unstructured grids' - Raise ImportError(msg) + raise ImportError(msg) # for unstructured grids, toss out points outside # projection limb (don't use those points in triangulation). if hasattr(data,'mask'): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-09-07 17:54:07
|
Revision: 8684 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8684&view=rev Author: jswhit Date: 2010-09-07 17:54:01 +0000 (Tue, 07 Sep 2010) Log Message: ----------- Add link in docstring. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-07 17:49:56 UTC (rev 8683) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-07 17:54:01 UTC (rev 8684) @@ -2019,8 +2019,8 @@ def removeparallels(self,pdict,lat=None): """ - Given a dictionary returned by ``drawparallels``, remove parallels - (latitude lines) and associated labels from the map. + Given a dictionary returned by :meth:`Basemap.drawparallels`, remove + parallels (latitude lines) and associated labels from the map. .. tabularcolumns:: |l|L| @@ -2285,8 +2285,8 @@ def removemeridians(self,mdict,lon=None): """ - Given a dictionary returned by ``drawmeridians``, remove meridians - (longitude lines) and associated labels from the map. + Given a dictionary returned by :meth:`Basemap.drawmeridians`, remove + meridians (longitude lines) and associated labels from the map. .. tabularcolumns:: |l|L| This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-09-07 23:15:34
|
Revision: 8685 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8685&view=rev Author: jswhit Date: 2010-09-07 23:15:27 +0000 (Tue, 07 Sep 2010) Log Message: ----------- make removemeridians, removeparallels work interactively Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-07 17:54:01 UTC (rev 8684) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-07 23:15:27 UTC (rev 8685) @@ -2017,7 +2017,7 @@ if v == ([], []): del linecolls[k] return linecolls - def removeparallels(self,pdict,lat=None): + def removeparallels(self,pdict,lat=None,ax=None): """ Given a dictionary returned by :meth:`Basemap.drawparallels`, remove parallels (latitude lines) and associated labels from the map. @@ -2029,6 +2029,7 @@ ============== ==================================================== lat latitude value to remove (Default None, removes all of them) + ax axes instance (overrides default axes instance) ============== ==================================================== """ if lat is not None and lat not in pdict.keys(): @@ -2038,7 +2039,16 @@ tup = pdict[key] for item in tup: for x in item: - x.remove() + try: + x.remove() + # might already be removed, if so + # don't do anything (exit silently). + except ValueError: + pass + # get current axes instance (if none specified). + ax = ax or self._check_ax() + # set axes limits to fit map region. + self.set_axes_limits(ax=ax) def drawmeridians(self,meridians,color='k',linewidth=1., zorder=None,\ dashes=[1,1],labels=[0,0,0,0],labelstyle=None,\ @@ -2295,6 +2305,7 @@ ============== ==================================================== lon longitude value to remove (Default None, removes all of them) + ax axes instance (overrides default axes instance) ============== ==================================================== """ if lon is not None and lon not in mdict.keys(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-09-08 12:21:57
|
Revision: 8687 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8687&view=rev Author: jswhit Date: 2010-09-08 12:21:50 +0000 (Wed, 08 Sep 2010) Log Message: ----------- don't raise exception if parallel or meridian already removed. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-08 12:00:32 UTC (rev 8686) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-08 12:21:50 UTC (rev 8687) @@ -4151,4 +4151,8 @@ def remove(self): for item in self: for x in item: - x.remove() + try: + x.remove() + except ValueError: + # don't raise an error if item already removed + pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-09-08 13:48:35
|
Revision: 8689 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8689&view=rev Author: jswhit Date: 2010-09-08 13:48:29 +0000 (Wed, 08 Sep 2010) Log Message: ----------- cleanup previous commit. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-08 13:47:13 UTC (rev 8688) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-08 13:48:29 UTC (rev 8689) @@ -2018,6 +2018,7 @@ if v == ([], []): del linecolls[k] # add a remove method to each tuple. linecolls[k] = _tup(linecolls[k]) + # override __delitem__ in dict to call remove() on values. return _dict(linecolls) def drawmeridians(self,meridians,color='k',linewidth=1., zorder=None,\ @@ -2264,6 +2265,7 @@ if v == ([], []): del linecolls[k] # add a remove method to each tuple. linecolls[k] = _tup(linecolls[k]) + # override __delitem__ in dict to call remove() on values. return _dict(linecolls) def tissot(self,lon_0,lat_0,radius_deg,npts,ax=None,**kwargs): @@ -4149,11 +4151,7 @@ def remove(self): for item in self: for x in item: - try: - x.remove() - except ValueError: - # don't raise an error if item already removed - pass + x.remove() class _dict(dict): # override __delitem__ to first call remove method on values. def __delitem__(self,key): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-12-29 18:32:56
|
Revision: 8856 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8856&view=rev Author: jswhit Date: 2010-12-29 18:32:50 +0000 (Wed, 29 Dec 2010) Log Message: ----------- fix labelling of parallels on hammer map. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-12-29 18:05:38 UTC (rev 8855) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-12-29 18:32:50 UTC (rev 8856) @@ -1924,13 +1924,15 @@ if side in ['l','r']: nmax = int((self.ymax-self.ymin)/dy+1) yy = np.linspace(self.llcrnry,self.urcrnry,nmax) - # mollweide inverse transform undefined at South Pole - if self.projection == 'moll' and yy[0] < 1.e-4: - yy[0] = 1.e-4 if side == 'l': - xx = self.llcrnrx*np.ones(yy.shape,yy.dtype) - lons,lats = self(xx,yy,inverse=True) - lons = lons.tolist(); lats = lats.tolist() + if self.projection in _pseudocyl: + lats = np.linspace(-89.99,89,99,nmax) + lons = (self.projparams['lon_0']-180.)*np.ones(len(lats),lats.dtype) + xx, yy = self(lons, lats) + else: + xx = self.llcrnrx*np.ones(yy.shape,yy.dtype) + lons,lats = self(xx,yy,inverse=True) + lons = lons.tolist(); lats = lats.tolist() else: lons,lats = self(self.urcrnrx*np.ones(yy.shape,np.float32),yy,inverse=True) lons = lons.tolist(); lats = lats.tolist() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-12-29 18:36:47
|
Revision: 8858 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8858&view=rev Author: jswhit Date: 2010-12-29 18:36:40 +0000 (Wed, 29 Dec 2010) Log Message: ----------- fix labelling of parallels on right of Hammer map. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-12-29 18:33:34 UTC (rev 8857) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-12-29 18:36:40 UTC (rev 8858) @@ -1934,8 +1934,14 @@ lons,lats = self(xx,yy,inverse=True) lons = lons.tolist(); lats = lats.tolist() else: - lons,lats = self(self.urcrnrx*np.ones(yy.shape,np.float32),yy,inverse=True) - lons = lons.tolist(); lats = lats.tolist() + if self.projection in _pseudocyl: + lats = np.linspace(-89.99,89,99,nmax) + lons = (self.projparams['lon_0']+180.)*np.ones(len(lats),lats.dtype) + xx, yy = self(lons, lats) + else: + xx = self.urcrnrx*np.ones(yy.shape,yy.dtype) + lons,lats = self(xx,yy,inverse=True) + lons = lons.tolist(); lats = lats.tolist() if max(lons) > 1.e20 or max(lats) > 1.e20: raise ValueError,'inverse transformation undefined - please adjust the map projection region' # adjust so 0 <= lons < 360 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2010-12-29 18:50:16
|
Revision: 8859 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8859&view=rev Author: jswhit Date: 2010-12-29 18:50:10 +0000 (Wed, 29 Dec 2010) Log Message: ----------- improve labelling of parallels on pseudo-cylindrical projections (like hammer, mollweide) Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-12-29 18:36:40 UTC (rev 8858) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-12-29 18:50:10 UTC (rev 8859) @@ -2010,14 +2010,30 @@ else: xlab = self.llcrnrx xlab = xlab-xoffset - t = ax.text(xlab,yy[n],latlab,horizontalalignment='right',verticalalignment='center',**kwargs) + if self.projection in _pseudocyl: + if lat>0: + t=ax.text(xlab,yy[n],latlab,horizontalalignment='right',verticalalignment='bottom',**kwargs) + elif lat<0: + t=ax.text(xlab,yy[n],latlab,horizontalalignment='right',verticalalignment='top',**kwargs) + else: + t=ax.text(xlab,yy[n],latlab,horizontalalignment='right',verticalalignment='center',**kwargs) + else: + t=ax.text(xlab,yy[n],latlab,horizontalalignment='right',verticalalignment='center',**kwargs) elif side == 'r': if self.projection in _pseudocyl: xlab,ylab = self(lon_0+179.9,lat) else: xlab = self.urcrnrx xlab = xlab+xoffset - t = ax.text(xlab,yy[n],latlab,horizontalalignment='left',verticalalignment='center',**kwargs) + if self.projection in _pseudocyl: + if lat>0: + t=ax.text(xlab,yy[n],latlab,horizontalalignment='left',verticalalignment='bottom',**kwargs) + elif lat<0: + t=ax.text(xlab,yy[n],latlab,horizontalalignment='left',verticalalignment='top',**kwargs) + else: + t=ax.text(xlab,yy[n],latlab,horizontalalignment='left',verticalalignment='center',**kwargs) + else: + t=ax.text(xlab,yy[n],latlab,horizontalalignment='left',verticalalignment='center',**kwargs) elif side == 'b': t = ax.text(xx[n],self.llcrnry-yoffset,latlab,horizontalalignment='center',verticalalignment='top',**kwargs) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2011-01-04 14:05:37
|
Revision: 8880 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8880&view=rev Author: jswhit Date: 2011-01-04 14:05:31 +0000 (Tue, 04 Jan 2011) Log Message: ----------- beginnings of support for astronomical conventions for longitude (via 'celestial' keyword). Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2011-01-04 00:45:25 UTC (rev 8879) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2011-01-04 14:05:31 UTC (rev 8880) @@ -255,6 +255,8 @@ Allowed values are ``C``, ``SW``, ``S``, ``SE``, ``E``, ``NE``, ``N``, ``NW``, and ``W``. + celestial use astronomical conventions for longitude (i.e. + negative longitudes to the east of 0). Default False. ax set default axes instance (default None - matplotlib.pyplot.gca() may be used to get the current axes instance). @@ -443,6 +445,7 @@ boundinglat=None, fix_aspect=True, anchor='C', + celestial=False, ax=None): # docstring is added after __init__ method definition @@ -451,6 +454,8 @@ self.fix_aspect = fix_aspect # where to put plot in figure (default is 'C' or center) self.anchor = anchor + # geographic or celestial coords? + self.celestial = celestial # map projection. self.projection = projection @@ -887,8 +892,13 @@ Input arguments lon, lat can be either scalar floats, sequences, or numpy arrays. """ - return self.projtran(x,y,inverse=inverse) + if self.celestial and not inverse: + x = -x + xout,yout = self.projtran(x,y,inverse=inverse) + if self.celestial and inverse: + xout = -xout + def makegrid(self,nx,ny,returnxy=False): """ return arrays of shape (ny,nx) containing lon,lat coordinates of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2011-01-04 14:16:42
|
Revision: 8881 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8881&view=rev Author: jswhit Date: 2011-01-04 14:16:36 +0000 (Tue, 04 Jan 2011) Log Message: ----------- get parallels to label on correct side when celestial=True Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2011-01-04 14:05:31 UTC (rev 8880) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2011-01-04 14:16:36 UTC (rev 8881) @@ -893,10 +893,17 @@ sequences, or numpy arrays. """ if self.celestial and not inverse: - x = -x + try: + x = -x + except TypeError: + x = [-xx for xx in x] xout,yout = self.projtran(x,y,inverse=inverse) if self.celestial and inverse: - xout = -xout + try: + xout = -xout + except: + xout = [-xx for xx in xout] + return xout,yout def makegrid(self,nx,ny,returnxy=False): @@ -1937,7 +1944,10 @@ if side == 'l': if self.projection in _pseudocyl: lats = np.linspace(-89.99,89,99,nmax) - lons = (self.projparams['lon_0']-180.)*np.ones(len(lats),lats.dtype) + if self.celestial: + lons = (self.projparams['lon_0']+180.)*np.ones(len(lats),lats.dtype) + else: + lons = (self.projparams['lon_0']-180.)*np.ones(len(lats),lats.dtype) xx, yy = self(lons, lats) else: xx = self.llcrnrx*np.ones(yy.shape,yy.dtype) @@ -1946,7 +1956,10 @@ else: if self.projection in _pseudocyl: lats = np.linspace(-89.99,89,99,nmax) - lons = (self.projparams['lon_0']+180.)*np.ones(len(lats),lats.dtype) + if self.celestial: + lons = (self.projparams['lon_0']-180.)*np.ones(len(lats),lats.dtype) + else: + lons = (self.projparams['lon_0']+180.)*np.ones(len(lats),lats.dtype) xx, yy = self(lons, lats) else: xx = self.urcrnrx*np.ones(yy.shape,yy.dtype) @@ -2016,7 +2029,10 @@ t = None if side == 'l': if self.projection in _pseudocyl: - xlab,ylab = self(lon_0-179.9,lat) + if self.celestial: + xlab,ylab = self(lon_0+179.9,lat) + else: + xlab,ylab = self(lon_0-179.9,lat) else: xlab = self.llcrnrx xlab = xlab-xoffset @@ -2031,7 +2047,10 @@ t=ax.text(xlab,yy[n],latlab,horizontalalignment='right',verticalalignment='center',**kwargs) elif side == 'r': if self.projection in _pseudocyl: - xlab,ylab = self(lon_0+179.9,lat) + if self.celestial: + xlab,ylab = self(lon_0-179.9,lat) + else: + xlab,ylab = self(lon_0+179.9,lat) else: xlab = self.urcrnrx xlab = xlab+xoffset This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2011-01-04 20:36:28
|
Revision: 8883 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8883&view=rev Author: jswhit Date: 2011-01-04 20:36:21 +0000 (Tue, 04 Jan 2011) Log Message: ----------- make celestial=True imply resolution=None, labelstyle="+/=" by default. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2011-01-04 20:24:12 UTC (rev 8882) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2011-01-04 20:36:21 UTC (rev 8883) @@ -257,6 +257,7 @@ ``N``, ``NW``, and ``W``. celestial use astronomical conventions for longitude (i.e. negative longitudes to the east of 0). Default False. + Implies ``resolution=None``. ax set default axes instance (default None - matplotlib.pyplot.gca() may be used to get the current axes instance). @@ -773,7 +774,10 @@ # set defaults for area_thresh. self.resolution = resolution - if area_thresh is None and resolution is not None: + # celestial=True implies resolution=None (no coastlines). + if self.celestial: + self.resolution=None + if area_thresh is None and self.resolution is not None: if resolution == 'c': area_thresh = 10000. elif resolution == 'l': @@ -857,7 +861,7 @@ # currently only used in is_land method. self.landpolygons=[] self.lakepolygons=[] - if resolution is not None and len(self.coastpolygons) > 0: + if self.resolution is not None and len(self.coastpolygons) > 0: #self.islandinlakepolygons=[] #self.lakeinislandinlakepolygons=[] x, y = zip(*self.coastpolygons) @@ -1840,6 +1844,9 @@ associated with each parallel. Deleting an item from the dictionary removes the corresponding parallel from the plot. """ + # if celestial=True, don't use "N" and "S" labels. + if labelstyle is None and self.celestial: + labelstyle="+/-" # get current axes instance (if none specified). ax = ax or self._check_ax() # don't draw meridians past latmax, always draw parallel at latmax. @@ -2135,6 +2142,9 @@ associated with each meridian. Deleting an item from the dictionary removes the correpsonding meridian from the plot. """ + # if celestial=True, don't use "E" and "W" labels. + if labelstyle is None and self.celestial: + labelstyle="+/-" # get current axes instance (if none specified). ax = ax or self._check_ax() # don't draw meridians past latmax, always draw parallel at latmax. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |