Skip to content

Commit

Permalink
Rename rHEALPix to RectangularHealpix.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelson committed Feb 23, 2018
1 parent 89d6076 commit 6886196
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
20 changes: 10 additions & 10 deletions docs/source/crs/projections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -414,34 +414,34 @@ OSNI
ax.gridlines()


SouthPolarStereo
----------------
RectangularHealpix
------------------

.. autoclass:: cartopy.crs.SouthPolarStereo
.. autoclass:: cartopy.crs.RectangularHealpix

.. plot::

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

plt.figure(figsize=(3, 3))
ax = plt.axes(projection=ccrs.SouthPolarStereo())
plt.figure(figsize=(4, 3))
ax = plt.axes(projection=ccrs.RectangularHealpix())
ax.coastlines(resolution='110m')
ax.gridlines()


rHEALPix
--------
SouthPolarStereo
----------------

.. autoclass:: cartopy.crs.rHEALPix
.. autoclass:: cartopy.crs.SouthPolarStereo

.. plot::

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

plt.figure(figsize=(4, 3))
ax = plt.axes(projection=ccrs.rHEALPix())
plt.figure(figsize=(3, 3))
ax = plt.axes(projection=ccrs.SouthPolarStereo())
ax.coastlines(resolution='110m')
ax.gridlines()

Expand Down
24 changes: 14 additions & 10 deletions lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def filter_last(t):

# filter out any non-valid linear rings
processed_ls = [linear_ring for linear_ring in processed_ls if
len(linear_ring.coords) > 2]
len(linear_ring.coords) > 3]

linear_rings = [sgeom.LinearRing(line) for line in processed_ls]

Expand Down Expand Up @@ -1955,16 +1955,19 @@ def y_limits(self):
semiminor_axis=6371007.181))


class rHEALPix(Projection):
class RectangularHealpix(Projection):
"""
The rHEALPix projection is an extension of the HEALPix to present squares
(rather than triangles) at the north and south poles.
Also known as rHEALPix in proj.4, this projection is an extension of the
Healpix projection to present rectangles, rather than triangles, at the north
and south poles.
Parameters
----------
central_longitude
north_square: int
The position for the north pole square. Must be one of 0, 1, 2 or 3.
0 would have the north pole square aligned with the left-most square,
and 3 would be aligned with the right-most.
south_square: int
The position for the south pole square. Must be one of 0, 1, 2 or 3.
Expand All @@ -1982,24 +1985,25 @@ def __init__(self, central_longitude=0, north_square=0, south_square=0):
('north_square', north_square),
('south_square', south_square),
('lon_0', central_longitude)]
super(rHEALPix, self).__init__(proj4_params)
super(RectangularHealpix, self).__init__(proj4_params)

# Boundary is based on units of m, with a standard spherical ellipse.
# The hard-coded scale is the reason for not accepting the globe
# keyword. The scale changes based on the size of the semi-major axis.
nrth_x_pos = (north_square - 2) * 1e7
sth_x_pos = (south_square - 2) * 1e7
top = 5.05e6
top = 5.03e6
max_v = 2e7

points = [[2e7, -5e6],
[2e7, top],
points = [[max_v, -5e6],
[max_v, top],
[nrth_x_pos + 1e7, top],
[nrth_x_pos + 1e7, 1.5e7],
[nrth_x_pos, 1.5e7],
[nrth_x_pos, top],
[-2e7, top]]
[-max_v, top]]
if south_square != 0:
points.append([-2e7, -top])
points.append([-max_v, -top])
points.extend([[sth_x_pos, -5e6],
[sth_x_pos, -1.5e7],
[sth_x_pos + 1e7, -1.5e7],
Expand Down
9 changes: 5 additions & 4 deletions lib/cartopy/tests/test_crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,18 @@ def test_utm(self):
decimal=1)


def test_rHEALPix_defaults():
crs = ccrs.rHEALPix()
def test_RectangularHealpix_defaults():
crs = ccrs.RectangularHealpix()
assert crs.proj4_params == {'ellps': 'WGS84',
'lon_0': 0,
'north_square': 0,
'proj': 'rhealpix',
'south_square': 0}


def test_rHEALPix_params():
crs = ccrs.rHEALPix(central_longitude=20, north_square=1, south_square=2)
def test_RectangularHealpix_params():
crs = ccrs.RectangularHealpix(central_longitude=20, north_square=1,
south_square=2)
assert crs.proj4_params == {'ellps': 'WGS84',
'lon_0': 20,
'north_square': 1,
Expand Down

0 comments on commit 6886196

Please sign in to comment.