Skip to content

Commit

Permalink
Merge pull request #88 from cdeil/healpy-intersphinx
Browse files Browse the repository at this point in the history
Fix docs intersphinx links to healpy
  • Loading branch information
cdeil committed Jun 25, 2018
2 parents fbcd02f + d982a9e commit b7a787c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
19 changes: 11 additions & 8 deletions astropy_healpix/healpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
interpolate_bilinear_lonlat)

RAD2DEG = 180 / np.pi
PI_2 = np.pi / 2

__all__ = ['nside2resol',
'nside2pixarea',
Expand Down Expand Up @@ -45,9 +46,9 @@ def _lonlat_to_healpy(lon, lat, lonlat=False):
else:
lat, lon = lat.to(u.rad).value, lon.to(u.rad).value
if np.isscalar(lon):
return 0.5 * np.pi - lat, lon
return PI_2 - lat, lon
else:
lat = np.subtract(0.5 * np.pi, lat, out=lat)
lat = np.subtract(PI_2, lat, out=lat)
return lat, lon


Expand All @@ -59,7 +60,7 @@ def _healpy_to_lonlat(theta, phi, lonlat=False):
lon = np.asarray(theta) / RAD2DEG
lat = np.asarray(phi) / RAD2DEG
else:
lat = np.pi / 2. - np.asarray(theta)
lat = PI_2 - np.asarray(theta)
lon = np.asarray(phi)
return u.Quantity(lon, u.rad, copy=False), u.Quantity(lat, u.rad, copy=False)

Expand Down Expand Up @@ -158,15 +159,15 @@ def boundaries(nside, pix, step=1, nest=False):


def vec2ang(vectors, lonlat=False):
"""Drop-in replacement for healpy `~healpy.vec2ang`."""
"""Drop-in replacement for healpy `~healpy.pixelfunc.vec2ang`."""
x, y, z = vectors.transpose()
rep_car = CartesianRepresentation(x, y, z)
rep_sph = rep_car.represent_as(UnitSphericalRepresentation)
return _lonlat_to_healpy(rep_sph.lon.ravel(), rep_sph.lat.ravel(), lonlat=lonlat)


def ang2vec(theta, phi, lonlat=False):
"""Drop-in replacement for healpy `~healpy.ang2vec`."""
"""Drop-in replacement for healpy `~healpy.pixelfunc.ang2vec`."""
lon, lat = _healpy_to_lonlat(theta, phi, lonlat=lonlat)
rep_sph = UnitSphericalRepresentation(lon, lat)
rep_car = rep_sph.represent_as(CartesianRepresentation)
Expand All @@ -175,19 +176,21 @@ def ang2vec(theta, phi, lonlat=False):

def get_interp_weights(nside, theta, phi=None, nest=False, lonlat=False):
"""
Drop-in replacement for healpy `~healpy.get_interp_weights`, although
note that the order of the weights and pixels may differ.
Drop-in replacement for healpy `~healpy.pixelfunc.get_interp_weights`.
Although note that the order of the weights and pixels may differ.
"""
# if phi is not given, theta is interpreted as pixel number
if phi is None:
theta, phi = pix2ang(nside, ipix=theta, nest=nest)

lon, lat = _healpy_to_lonlat(theta, phi, lonlat=lonlat)
return bilinear_interpolation_weights(lon, lat, nside, order='nested' if nest else 'ring')


def get_interp_val(m, theta, phi, nest=False, lonlat=False):
"""
Drop-in replacement for healpy `~healpy.get_interp_val`.
Drop-in replacement for healpy `~healpy.pixelfunc.get_interp_val`.
"""
lon, lat = _healpy_to_lonlat(theta, phi, lonlat=lonlat)
return interpolate_bilinear_lonlat(lon, lat, m, order='nested' if nest else 'ring')
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@

# -- General configuration ----------------------------------------------------

intersphinx_mapping.pop('scipy', None)
intersphinx_mapping.pop('h5py', None)
intersphinx_mapping['healpy'] = ('https://healpy.readthedocs.io/en/latest/', None)


# By default, highlight as Python 3.
highlight_language = 'python3'

Expand Down

0 comments on commit b7a787c

Please sign in to comment.