healpix_geo.nested.kth_neighbours#
- healpix_geo.nested.kth_neighbours(ipix, depth, ring, num_threads=0)#
Get the kth ring of neighbouring cells around some HEALPix cells at a given depth.
This method returns a \(N\) x \(8 k\) np.uint64 numpy array containing the neighbours of each cell of the \(N\) sized ipix array. This method is wrapped around the kth_neighbours method of the cdshealpix Rust crate.
- Parameters:
ipix (numpy.ndarray) – The HEALPix cell indexes given as a np.uint64 numpy array.
depth (
int) – The depth of the HEALPix cells.ring (
int) – The number of rings. ring=0 returns just the input cell ids, ring=1 returns the 8 (or 7) immediate neighbours, ring=2 returns the 16 neighbours of the immediate neighbours, and so on.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:
neighbours (numpy.ndarray) – A \(N\) x \(8 k\) np.int64 numpy array containing the kth ring neighbours of each cell.
- Raises:
ValueError – When the HEALPix cell indexes given have values out of \([0, 4^{29 - depth}[\).
Examples
>>> from healpix_geo.nested import kth_neighbours >>> import numpy as np >>> ipix = np.array([42, 6, 10]) >>> depth = 12 >>> ring = 3 >>> neighbours = kth_neighbours(ipix, depth, ring) >>> neighbours array([[ 72701297, 72701299, 72701305, 72701307, 72701393, 72701395, 72701401, 72701404, 72701405, 72701301, 72701300, 136, 137, 140, 141, 135, 133, 47, 45, 39, 37, 36, 33, 32], [150994941, 150994943, 72701269, 72701271, 72701277, 72701279, 72701301, 95070907, 95070905, 95070904, 95070893, 95070892, 95070889, 95070888, 32, 33, 36, 37, 48, 49, 27, 25, 19, 17], [ 72701265, 72701267, 72701273, 72701275, 72701297, 72701299, 72701305, 72701308, 72701309, 72701269, 72701268, 40, 41, 44, 45, 39, 37, 15, 13, 7, 5, 4, 1, 0]])