From: <js...@us...> - 2008-12-08 17:00:15
|
Revision: 6514 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6514&view=rev Author: jswhit Date: 2008-12-08 17:00:12 +0000 (Mon, 08 Dec 2008) Log Message: ----------- fix drawlsmask so it works for cylindrical projections that have limits outside -180,180 Modified Paths: -------------- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2008-12-08 16:31:48 UTC (rev 6513) +++ trunk/toolkits/basemap/Changelog 2008-12-08 17:00:12 UTC (rev 6514) @@ -1,4 +1,6 @@ version 0.99.2 (not yet released) + * fix drawlsmask method so that it works for cylindrical + projections with limits outside (-180,180). * added 'scale' keyword to bluemarble and warpimage methods to downsample image background. * Made lat_ts default to 0 for mercator. Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 16:31:48 UTC (rev 6513) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008-12-08 17:00:12 UTC (rev 6514) @@ -3082,12 +3082,25 @@ lsmask_lats = np.arange(-90.+0.5*delta,90.,delta) lsmask = np.reshape(np.fromstring(lsmaskf.read(),np.uint8),(nlats,nlons)) lsmaskf.close() - # instance variable lsmask is set on first invocation, - # it contains the land-sea mask interpolated to the native - # projection grid. Further calls to drawlsmask will not - # redo the interpolation (unless a new land-sea mask is passed - # in via the lsmask, lsmask_lons, lsmask_lats keywords). + # instance variable lsmask is set on first invocation, + # it contains the land-sea mask interpolated to the native + # projection grid. Further calls to drawlsmask will not + # redo the interpolation (unless a new land-sea mask is passed + # in via the lsmask, lsmask_lons, lsmask_lats keywords). + # is it a cylindrical projection whose limits lie + # outside the limits of the image? + cylproj = self.projection in _cylproj and \ + (self.urcrnrlon > lsmask_lons[-1] or \ + self.llcrnrlon < lsmask_lons[0]) + if cylproj: + # stack grids side-by-side (in longitiudinal direction), so + # any range of longitudes may be plotted on a world map. + lsmask_lons = \ + np.concatenate((lsmask_lons,lsmask_lons+360),1) + lsmask = \ + np.concatenate((lsmask,lsmask),1) + # transform mask to nx x ny regularly spaced native projection grid # nx and ny chosen to have roughly the same horizontal # resolution as mask. @@ -3097,7 +3110,7 @@ if self.projection == 'cyl': dx = lsmask_lons[1]-lsmask_lons[0] else: - dx = 2.*math.pi*self.rmajor/float(nlons) + dx = (np.pi/180.)*(lsmask_lons[1]-lsmask_lons[0])*self.rmajor nx = int((self.xmax-self.xmin)/dx)+1; ny = int((self.ymax-self.ymin)/dx)+1 # interpolate rgba values from proj='cyl' (geographic coords) # to a rectangular map projection grid. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |