healpix_geo.ring.bilinear_interpolation#
- healpix_geo.ring.bilinear_interpolation(longitude, latitude, depth, *, ellipsoid='sphere', num_threads=0)#
Get the cell ids and weights necessary to bilinearly interpolate the given values.
- Parameters:
longitude (
numpy.ndarray) – The longitudes of the input points, in degrees.latitude (
numpy.ndarray) – The latitudes of the input points, in degrees.depth (
int) – The depth of the HEALPix cells.ellipsoid (ellipsoid-like, default:
"sphere") – Reference ellipsoid to evaluate healpix on. If the reference ellipsoid is spherical, this will return the same result ascdshealpix.nested.vertices().num_threads (
int, 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:
cell_ids (
numpy.ndarray) – The neighbours above and below the given points as a \(N\) x \(4\) masked array.weights (
numpy.ndarray) – The associated weights as a \(N\) x \(4\) masked array.
- Raises:
ValueError – When the HEALPix cell indexes given have values out of \([0, 4^{29 - depth})\).
Examples
>>> from healpix_geo.ring import bilinear_interpolation >>> import numpy as np
Define coordinates
>>> lon = np.array([-15.0, -10.0, -5.0, 0.0, 5.0]) >>> lat = np.array([30.0, 35.0, 40.0, 45.0, 50.0])
Compute interpolation weights
>>> cell_ids, weights = bilinear_interpolation(lon, lat, depth=6, ellipsoid="WGS84") >>> cell_ids MArray( array([[12661, 12405, 12404, 12149], [10872, 10617, 10616, 10360], [ 9340, 9085, 9084, 8828], [ 7320, 7080, 7563, 7319], [ 5943, 5727, 5726, 5514]], dtype=uint64), array([[False, False, False, False], [False, False, False, False], [False, False, False, False], [False, False, False, False], [False, False, False, False]]) ) >>> weights MArray( array([[0.22596183, 0.68795133, 0.02128467, 0.06480216], [0.15244623, 0.78751507, 0.00973729, 0.05030142], [0.04859157, 0.12318081, 0.23429192, 0.5939357 ], [0.32719215, 0.17280785, 0.32719215, 0.17280785], [0.14255714, 0.34522269, 0.1497 , 0.36252017]]), array([[False, False, False, False], [False, False, False, False], [False, False, False, False], [False, False, False, False], [False, False, False, False]]) )