healpy.pixelfunc.get_interp_weights

healpy.pixelfunc.get_interp_weights(nside, theta, phi=None, nest=False, lonlat=False)

Return the 4 closest pixels on the two rings above and below the location and corresponding weights. Weights are provided for bilinear interpolation along latitude and longitude

Parameters:
nsideint

the healpix nside

theta, phifloat, scalar or array-like

if phi is not given, theta is interpreted as pixel number, otherwise theta[rad],phi[rad] are angular coordinates

nestbool

if True, NESTED ordering, otherwise RING ordering.

lonlatbool

If True, input angles are assumed to be longitude and latitude in degree, otherwise, they are co-latitude and longitude in radians.

Returns:
restuple of length 2

contains pixel numbers in res[0] and weights in res[1]. Usual numpy broadcasting rules apply.

Examples

Note that some of the test inputs below that are on pixel boundaries such as theta=pi/2, phi=pi/2, have a tiny value of 1e-15 added to them to make them reproducible on i386 machines using x87 floating point instruction set (see https://github.com/healpy/healpy/issues/528).

>>> import healpy as hp
>>> pix, weights = hp.get_interp_weights(1, 0)
>>> print(pix)
[0 1 4 5]
>>> weights
array([ 1.,  0.,  0.,  0.])
>>> pix, weights = hp.get_interp_weights(1, 0, 0)
>>> print(pix)
[1 2 3 0]
>>> weights
array([ 0.25,  0.25,  0.25,  0.25])
>>> pix, weights = hp.get_interp_weights(1, 0, 90, lonlat=True)
>>> print(pix)
[1 2 3 0]
>>> weights
array([ 0.25,  0.25,  0.25,  0.25])
>>> pix, weights = hp.get_interp_weights(1, [0, np.pi/2 + 1e-15], 0)
>>> print(pix)
[[ 1  4]
 [ 2  5]
 [ 3 11]
 [ 0  8]]
>>> np.testing.assert_allclose(
...     weights,
...     np.array([[ 0.25,  1.  ],
...               [ 0.25,  0.  ],
...               [ 0.25,  0.  ],
...               [ 0.25,  0.  ]]), rtol=0, atol=1e-14)