cdshealpix.nested.bilinear_interpolation

cdshealpix.nested.bilinear_interpolation(lon, lat, depth, num_threads=0)

Compute the HEALPix bilinear interpolation from sky coordinates.

For each (lon, lat) sky position given, this function returns the 4 HEALPix cells that share the nearest cross of the position in the nested configuration.

  1. x

If x is the position, then the 4 annotated HEALPix cells will be returned along with their weights. These 4 weights sum up to 1.

Parameters:
lonastropy.coordinates.Longitude

The longitudes of the sky coordinates.

latastropy.coordinates.Latitude

The latitudes of the sky coordinates.

depthint

The depth of the HEALPix cells

num_threadsint, optional

Specifies the number of threads to use for the computation. Default to 0 means it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set), or the number of logical CPUs (otherwise)

Returns:
pixels, weights: (numpy.ma.masked_array, numpy.ma.masked_array)

\(N \times 4\) arrays where N is the number of lon (and lat) given. For each given sky position, 4 HEALPix cells in the nested configuration are returned. Each cell is associated with a specific weight. The 4 weights sum up to 1. For numpy masked arrays, invalid positions are flaged with a True while valid coordinates are marked as False. See numpy docs for more information. https://numpy.org/doc/stable/reference/maskedarray.html

Examples

>>> from cdshealpix import bilinear_interpolation
>>> from astropy.coordinates import Longitude, Latitude
>>> import astropy.units as u
>>> import numpy as np
>>> lon = Longitude([10, 25], u.deg)
>>> lat = Latitude([5, 10], u.deg)
>>> depth = 5
>>> ipix, weights = bilinear_interpolation(lon, lat, depth)