This Python 3.3 module implements the rHEALPix map projection.
CHANGELOG:
NOTE:
All lengths are measured in meters and all angles are measured in radians unless indicated otherwise. By ‘ellipsoid’ below, i mean an oblate ellipsoid of revolution.
Rearrange point (x, y) in the HEALPix projection by combining the polar triangles into two polar squares. Put the north polar square in position north_square and the south polar square in position south_square. If inverse = True, uncombine the polar triangles.
INPUT:
EXAMPLES:
>>> u, v = -pi/4, pi/3
>>> x, y = combine_triangles(u, v)
>>> print(my_round((x, y), 15))
(-1.8325957145940459, 1.5707963267948959)
>>> print(my_round(combine_triangles(x, y, inverse=True), 15))
(-0.78539816339744795, 1.0471975511965981)
>>> print(my_round((u, v), 15))
(-0.785398163397448, 1.047197551196598)
Return True if and only if the point (x, y) lies in the image of the rHEALPix projection of the unit sphere.
EXAMPLES:
>>> eps = 0 # Test boundary points.
>>> north_square, south_square = 0, 0
>>> rhp = [
... (-pi - eps, pi/4 + eps),
... (-pi + north_square*pi/2 - eps, pi/4 + eps),
... (-pi + north_square*pi/2 - eps, 3*pi/4 + eps),
... (-pi + (north_square + 1)*pi/2 + eps, 3*pi/4 + eps),
... (-pi + (north_square + 1)*pi/2 + eps, pi/4 + eps),
... (pi + eps, pi/4 + eps),
... (pi + eps,-pi/4 - eps),
... (-pi + (south_square + 1)*pi/2 + eps,-pi/4 - eps),
... (-pi + (south_square + 1)*pi/2 + eps,-3*pi/4 - eps),
... (-pi + south_square*pi/2 - eps,-3*pi/4 - eps),
... (-pi + south_square*pi/2 -eps,-pi/4 - eps),
... (-pi - eps,-pi/4 - eps)
... ]
>>> for p in rhp:
... if not in_rhealpix_image(*p):
... print('Fail')
...
>>> print(in_rhealpix_image(0, 0))
True
>>> print(in_rhealpix_image(0, pi/4 + 0.1))
False
Return a function object that wraps the rHEALPix projection and its inverse of an ellipsoid with major radius a and eccentricity e.
EXAMPLES:
>>> f = rhealpix(a=2, e=0, north_square=1, south_square=2)
>>> print(my_round(f(0, pi/3, radians=True), 15))
(-0.57495135977821499, 2.1457476865731109)
>>> p = (0, 60)
>>> q = f(*p, radians=False)
>>> print(my_round(q, 15))
(-0.57495135977821499, 2.1457476865731109)
>>> print(my_round(f(*q, radians=False, inverse=True), 15))
(5.9999999999999997e-15, 59.999999999999986)
>>> print(my_round(p, 15))
(0, 60)
OUTPUT:
Return a Sage Graphics object diagramming the rHEALPix projection boundary and polar triangles for the ellipsoid with major radius a and eccentricity e. Inessential graphics method. Requires Sage graphics methods.
Compute the signature functions of the rHEALPix map projection of an oblate ellipsoid with eccentricity e whose authalic sphere is the unit sphere. The north polar square is put in position north_square, and the south polar square is put in position south_square. Works when e = 0 (spherical case) too.
INPUT:
EXAMPLES:
>>> from numpy import arcsin
>>> print(my_round(rhealpix_ellipsoid(0, arcsin(2.0/3)), 15))
(0, 0.78539816339744795)
Compute the inverse of rhealpix_ellipsoid.
EXAMPLES:
>>> p = (0, pi/4)
>>> q = rhealpix_ellipsoid(*p)
>>> print(my_round(rhealpix_ellipsoid_inverse(*q), 15))
(0.0, 0.78539816339744795)
>>> print(my_round(p, 15))
(0, 0.785398163397448)
Compute the signature functions of the rHEALPix map projection of the unit sphere. The north polar square is put in position north_square, and the south polar square is put in position south_square.
INPUT:
EXAMPLES:
>>> print(my_round(rhealpix_sphere(0, pi/4), 15))
(-1.619978633413937, 2.307012183573304)
NOTE:
The polar squares are labeled 0, 1, 2, 3 from east to west like this:
east west
*---*---*---*---*
| 0 | 1 | 2 | 3 |
*---*---*---*---*
| | | | |
*---*---*---*---*
| 0 | 1 | 2 | 3 |
*---*---*---*---*
Compute the inverse of rhealpix_sphere().
EXAMPLES:
>>> p = (0, pi/4)
>>> q = rhealpix_sphere(*p)
>>> print(my_round(rhealpix_sphere_inverse(*q), 15))
(0.0, 0.78539816339744795)
>>> print(my_round(p, 15))
(0, 0.785398163397448)
Return a list of the planar vertices of the rHEALPix projection of the unit sphere.
Return the number of the polar triangle and region that (x, y) lies in. If inverse = False, then assume (x,y) lies in the image of the HEALPix projection of the unit sphere. If inverse = True, then assume (x,y) lies in the image of the (north_square, south_square)-rHEALPix projection of the unit sphere.
INPUT:
OUTPUT:
The pair (triangle_number, region). Here region equals ‘north_polar’ (polar), ‘south_polar’ (polar), or ‘equatorial’, indicating where (x, y) lies. If region = ‘equatorial’, then triangle_number = None. Suppose now that region != ‘equatorial’. If inverse = False, then triangle_number is the number (0, 1, 2, or 3) of the HEALPix polar triangle Z that (x, y) lies in. If inverse = True, then triangle_number is the number (0, 1, 2, or 3) of the HEALPix polar triangle that (x, y) will get moved into.
EXAMPLES:
>>> triangle(-pi/4, pi/4 + 0.1)
(1, 'north_polar')
>>> triangle(-3*pi/4 + 0.1, pi/2, inverse=True)
(1, 'north_polar')
NOTES:
In the HEALPix projection, the polar triangles are labeled 0–3 from east to west like this:
* * * *
* 0 * * 1 * * 2 * * 3 *
*-------*-------*-------*-------*
| | | | |
| | | | |
| | | | |
*-------*-------*-------*-------*
* 0 * * 1 * * 2 * * 3 *
* * * *
In the rHEALPix projection these polar triangles get rearranged into a square with the triangles numbered north_square and south_square remaining fixed. For example, if north_square = 1 and south_square = 3, then the triangles get rearranged this way:
North polar square: *-------*
| * 3 * |
| 0 * 2 |
| * 1 * |
----*-------*----
South polar square: ----*-------*----
| * 3 * |
| 2 * 0 |
| * 1 * |
*-------*