The pj_healpix Module¶
This Python 3.11 module implements the HEALPix map projection as described in [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.
Alexander Raichev (AR), 2013-01-26: Refactored code from release 0.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.
- rhealpixdggs.pj_healpix.healpix(a: float = 1, e: float = 0) Callable[[float, float, bool, bool], tuple[float, float]] ¶
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(tuple(x.tolist() for x in my_round(f(0, pi/3, radians=True), 15))) (0.574951359778215, 2.145747686573111) >>> p = (0, 60) >>> q = f(*p, radians=False); print(tuple(x.tolist() for x in my_round(q, 15))) (0.574951359778215, 2.145747686573111) >>> print(tuple(x.tolist() for x in my_round(f(*q, radians=False, inverse=True), 15))) (6e-15, 59.999999999999986) >>> print(my_round(p, 15)) (0, 60)
OUTPUT:
A function object of the form f(u, v, radians=False, inverse=False).
- rhealpixdggs.pj_healpix.healpix_ellipsoid(lam: float, phi: float, e: float = 0) tuple[float, float] ¶
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(tuple(x if type(x) is int else x.tolist() for x in my_round(healpix_ellipsoid(0, pi/7), 15))) (0, 0.511157237746422) >>> print(tuple(x if type(x) is int else x.tolist() for x in my_round(healpix_ellipsoid(0, pi/7, e=0.8), 15))) (0, 0.268484450857837)
- rhealpixdggs.pj_healpix.healpix_ellipsoid_inverse(x: float, y: float, e: float = 0) tuple[float, float] ¶
Compute the inverse of healpix_ellipsoid().
EXAMPLES:
>>> p = (0, pi/7) >>> q = healpix_ellipsoid(*p) >>> print(tuple(x if type(x) is int else x.tolist() for x in my_round(healpix_ellipsoid_inverse(*q), 15))) (0, 0.448798950512828) >>> print(my_round(p, 15)) (0, 0.448798950512828)
- rhealpixdggs.pj_healpix.healpix_sphere(lam: float, phi: float) tuple[float, float] ¶
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
- rhealpixdggs.pj_healpix.healpix_sphere_inverse(x: float, y: float) tuple[float, float] ¶
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
- rhealpixdggs.pj_healpix.healpix_vertices() list[tuple[float, float, float]] ¶
Return a list of the planar vertices of the HEALPix projection of the unit sphere.
- rhealpixdggs.pj_healpix.in_healpix_image(x: float, y: float) bool ¶
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