Skip to content

Commit eb6bf5c

Browse files
author
Jeff Whitaker
committed
pull request 6
1 parent fed1457 commit eb6bf5c

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

Changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
version 1.0.3 (not yet released)
2+
* bug fixes for celestial projections, and non-standard sphere
3+
radii (https://github.com/matplotlib/basemap/pull/6).
24
* fix bug in drawparallels that results in 'KeyError' when drawing
35
parallels very close together (0.1 degrees).
46
* fix constant in Robinson projection (update PJ_robin.c

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -887,20 +887,26 @@ def __call__(self,x,y,inverse=False):
887887
Input arguments lon, lat can be either scalar floats,
888888
sequences, or numpy arrays.
889889
"""
890+
if self.celestial:
891+
# don't assume center of map is at greenwich
892+
# (only relevant for cyl or pseudo-cyl projections)
893+
if (self.projection in _pseudocyl) or (self.projection in _cylproj):
894+
lon_0=self.projparams['lon_0']
895+
else:
896+
lon_0 = 0.
890897
if self.celestial and not inverse:
891898
try:
892-
x = -x
899+
x = 2.*lon_0-x
893900
except TypeError:
894-
x = [-xx for xx in x]
901+
x = [2*lon_0-xx for xx in x]
895902
xout,yout = self.projtran(x,y,inverse=inverse)
896903
if self.celestial and inverse:
897904
try:
898-
xout = -xout
905+
xout = -2.*lon_0-xout
899906
except:
900-
xout = [-xx for xx in xout]
907+
xout = [-2.*lon_0-xx for xx in xout]
901908
return xout,yout
902909

903-
904910
def makegrid(self,nx,ny,returnxy=False):
905911
"""
906912
return arrays of shape (ny,nx) containing lon,lat coordinates of
@@ -1892,7 +1898,9 @@ def drawparallels(self,circles,color='k',linewidth=1.,zorder=None, \
18921898
xd = (x[1:]-x[0:-1])**2
18931899
yd = (y[1:]-y[0:-1])**2
18941900
dist = np.sqrt(xd+yd)
1895-
split = dist > 500000.
1901+
#split = dist > 500000.
1902+
# normalize by radius of sphere
1903+
split = dist > 5000000./6370997.0*self.rmajor
18961904
if np.sum(split) and self.projection not in _cylproj:
18971905
ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist()
18981906
xl = []
@@ -2191,7 +2199,9 @@ def addlon(meridians,madd):
21912199
xd = (x[1:]-x[0:-1])**2
21922200
yd = (y[1:]-y[0:-1])**2
21932201
dist = np.sqrt(xd+yd)
2194-
split = dist > 500000.
2202+
#split = dist > 500000.
2203+
# normalize by radius of sphere
2204+
split = dist > 5000000./6370997.0*self.rmajor
21952205
if np.sum(split) and self.projection not in _cylproj:
21962206
ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist()
21972207
xl = []

0 commit comments

Comments
 (0)