8000 Minor cleanup to make functions more self consisntent · matplotlib/matplotlib@82f4176 · GitHub
[go: up one dir, main page]

Skip to content

Commit 82f4176

Browse files
committed
Minor cleanup to make functions more self consisntent
1 parent 32c7f42 commit 82f4176

File tree

1 file changed

+12
-15
lines changed
  • lib/matplotlib/projections

1 file changed

+12
-15
lines changed

lib/matplotlib/projections/geo.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ class AitoffTransform(_GeoTransform):
265265

266266
def transform_non_affine(self, ll):
267267
# docstring inherited
268-
longitude = ll[:, 0]
269-
latitude = ll[:, 1]
268+
longitude, latitude = ll.T
270269

271270
# Pre-compute some values
272271
half_long = longitude / 2.0
@@ -278,10 +277,9 @@ def transform_non_affine(self, ll):
278277
# We want unnormalized sinc. numpy.sinc gives us normalized
279278
sinc_alpha = np.sin(alpha) / alpha
280279

281-
xy = np.empty_like(ll, float)
282-
xy[:, 0] = (cos_latitude * np.sin(half_long)) / sinc_alpha
283-
xy[:, 1] = np.sin(latitude) / sinc_alpha
284-
return xy
280+
x = (cos_latitude * np.sin(half_long)) / sinc_alpha
281+
y = np.sin(latitude) / sinc_alpha
282+
return np.column_stack([x, y])
285283

286284
def inverted(self):
287285
# docstring inherited
@@ -405,9 +403,9 @@ def transform_non_affine(self, xy):
405403
# from Equations (7, 8) of
406404
# http://mathworld.wolfram.com/MollweideProjection.html
407405
theta = np.arcsin(y / np.sqrt(2))
408-
lon = (np.pi / (2 * np.sqrt(2))) * x / np.cos(theta)
409-
lat = np.arcsin((2 * theta + np.sin(2 * theta)) / np.pi)
410-
return np.column_stack([lon, lat])
406+
longitude = (np.pi / (2 * np.sqrt(2))) * x / np.cos(theta)
407+
latitude = np.arcsin((2 * theta + np.sin(2 * theta)) / np.pi)
408+
return np.column_stack([longitude, latitude])
411409

412410
def inverted(self):
413411
# docstring inherited
@@ -474,21 +472,20 @@ def __init__(self, center_longitude, center_latitude, resolution):
474472

475473
def transform_non_affine(self, xy):
476474
# docstring inherited
477-
x = xy[:, 0:1]
478-
y = xy[:, 1:2]
475+
x, y = xy.T
479476
clong = self._center_longitude
480477
clat = self._center_latitude
481478
p = np.maximum(np.hypot(x, y), 1e-9)
482479
c = 2 * np.arcsin(0.5 * p)
483480
sin_c = np.sin(c)
484481
cos_c = np.cos(c)
485482

486-
lat = np.arcsin(cos_c*np.sin(clat) +
487-
((y*sin_c*np.cos(clat)) / p))
488-
lon = clong + np.arctan(
483+
latitude = np.arcsin(cos_c*np.sin(clat) +
484+
((y*sin_c*np.cos(clat)) / p))
485+
longitude = clong + np.arctan(
489486
(x*sin_c) / (p*np.cos(clat)*cos_c - y*np.sin(clat)*sin_c))
490487

491-
return np.concatenate((lon, lat), 1)
488+
return np.column_stack([longitude, latitude])
492489

493490
def inverted(self):
494491
# docstring inherited

0 commit comments

Comments
 (0)
0