The pj_healpix Module

This Python 3.3 module implements the HEALPix map projection as described in [CaRo2007].

[CaRo2007]Mark R. Calabretta and Boudewijn F. Roukema, Mapping on the healpix grid, Monthly Notices of the Royal Astronomical Society 381 (2007), no. 2, 865–872.

CHANGELOG:

  • Alexander Raichev (AR), 2013-01-26: Refactored code from release 0.3.
  • AR, 2013-03-05: In in_healpix_image() increased eps to 1e-10 to decrease out-of-bounds errors i was getting when drawing figures.
  • AR, 2013-07-23: Ported to Python 3.3.

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.

rhealpix_dggs.pj_healpix.healpix(a=1, e=0)

Return a function object that wraps the HEALPix projection and its inverse of an ellipsoid with major radius a and eccentricity e.

EXAMPLES:

>>> f = healpix(a=2, e=0)
>>> 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:

  • A function object of the form f(u, v, radians=False, inverse=False).
rhealpix_dggs.pj_healpix.healpix_diagram(a=1, e=0, shade_polar_region=True)

Return a Sage Graphics object diagramming the HEALPix projection boundary and polar triangles for the ellipsoid with major radius a and eccentricity e. Inessential graphics method. Requires Sage graphics methods.

rhealpix_dggs.pj_healpix.healpix_ellipsoid(lam, phi, e=0)

Compute the signature functions of the HEALPix projection of an oblate ellipsoid with eccentricity e whose authalic sphere is the unit sphere. Works when e = 0 (spherical case) too.

INPUT:

  • lam, phi - Geodetic longitude-latitude coordinates in radians. Assume -pi <= lam < pi and -pi/2 <= phi <= pi/2.
  • e - Eccentricity of the oblate ellipsoid.

EXAMPLES:

>>> print(my_round(healpix_ellipsoid(0, pi/7), 15))
(0, 0.51115723774642197)
>>> print(my_round(healpix_ellipsoid(0, pi/7, e=0.8), 15))
(0, 0.26848445085783701)
rhealpix_dggs.pj_healpix.healpix_ellipsoid_inverse(x, y, e=0)

Compute the inverse of healpix_ellipsoid().

EXAMPLES:

>>> p = (0, pi/7)
>>> q = healpix_ellipsoid(*p)
>>> print(my_round(healpix_ellipsoid_inverse(*q), 15))
(0, 0.44879895051282798)
>>> print(my_round(p, 15))
(0, 0.448798950512828)
rhealpix_dggs.pj_healpix.healpix_sphere(lam, phi)

Compute the signature function of the HEALPix projection of the unit sphere.

INPUT:

  • lam, phi - Geodetic longitude-latitude coordinates in radians. Assume -pi <= lam < pi and -pi/2 <= phi <= pi/2.

EXAMPLES:

>>> print(healpix_sphere(0, arcsin(2.0/3)) == (0, pi/4))
True
rhealpix_dggs.pj_healpix.healpix_sphere_inverse(x, y)

Compute the inverse of the healpix_sphere().

INPUT:

  • x, y - Planar coordinates in meters in the image of the HEALPix projection of the unit sphere.

EXAMPLES:

>>> print(healpix_sphere_inverse(0, pi/4) == (0, arcsin(2.0/3)))
True
rhealpix_dggs.pj_healpix.healpix_vertices()

Return a list of the planar vertices of the HEALPix projection of the unit sphere.

rhealpix_dggs.pj_healpix.in_healpix_image(x, y)

Return True if and only if (x, y) lies in the image of the HEALPix projection of the unit sphere.

EXAMPLES:

>>> eps = 0     # Test boundary points.
>>> hp = [
... (-pi - eps, pi/4),
... (-3*pi/4, pi/2 + eps),
... (-pi/2, pi/4 + eps),
... (-pi/4, pi/2 + eps),
... (0, pi/4 + eps),
... (pi/4, pi/2 + eps),
... (pi/2, pi/4 + eps),
... (3*pi/4, pi/2 + eps),
... (pi + eps, pi/4),
... (pi + eps,-pi/4),
... (3*pi/4,-pi/2 - eps),
... (pi/2,-pi/4 - eps),
... (pi/4,-pi/2 - eps),
... (0,-pi/4 - eps),
... (-pi/4,-pi/2 - eps),
... (-pi/2,-pi/4 - eps),
... (-3*pi/4,-pi/2 - eps),
... (-pi - eps,-pi/4)
... ]
>>> for p in hp:
...     if not in_healpix_image(*p):
...             print('Fail')
... 
>>> in_healpix_image(0, 0)
True
>>> in_healpix_image(0, pi/4 + 0.1)
False

Previous topic

The utils Module

Next topic

The pj_rhealpix Module

This Page