healpix_geo.nested.kth_neighbourhood#
- healpix_geo.nested.kth_neighbourhood(ipix, depth, ring, num_threads=0)#
Get the kth ring neighbouring cells of some HEALPix cells at a given depth.
This method returns a \(N\) x \((2 k + 1)^2\) np.uint64 numpy array containing the neighbours of each cell of the \(N\) sized ipix array. This method is wrapped around the kth_neighbourhood method from 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 8 (or 7) immediate neighbours plus their immediate neighbours (a total of 24 cells), 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 \((2 k + 1)^2\) np.int64 numpy array containing the kth ring neighbours of each cell. The \(5^{th}\) element corresponds to the index of HEALPix cell from which the neighbours are evaluated. All its 8 neighbours occup the remaining elements of the line.
- Raises:
ValueError – When the HEALPix cell indexes given have values out of \([0, 4^{29 - depth}[\).
Examples
>>> from healpix_geo.nested import kth_neighbourhood >>> import numpy as np >>> ipix = np.array([42, 6, 10]) >>> depth = 12 >>> ring = 3 >>> neighbours = kth_neighbourhood(ipix, depth, ring) >>> neighbours array([[ 42, 72701309, 72701311, 72701397, 128, 129, 43, 41, 40, 72701302, 72701308, 72701310, 72701396, 72701398, 72701399, 72701303, 130, 131, 134, 132, 46, 44, 38, 35, 34, 72701297, 72701299, 72701305, 72701307, 72701393, 72701395, 72701401, 72701404, 72701405, 72701301, 72701300, 136, 137, 140, 141, 135, 133, 47, 45, 39, 37, 36, 33, 32], [ 6, 1, 3, 9, 12, 13, 7, 5, 4, 95070890, 95070906, 95070895, 95070894, 95070891, 0, 2, 8, 10, 11, 14, 15, 26, 24, 18, 16, 150994941, 150994943, 72701269, 72701271, 72701277, 72701279, 72701301, 95070907, 95070905, 95070904, 95070893, 95070892, 95070889, 95070888, 32, 33, 36, 37, 48, 49, 27, 25, 19, 17], [ 10, 72701277, 72701279, 72701301, 32, 33, 11, 9, 8, 72701270, 72701276, 72701278, 72701300, 72701302, 72701303, 72701271, 34, 35, 38, 36, 14, 12, 6, 3, 2, 72701265, 72701267, 72701273, 72701275, 72701297, 72701299, 72701305, 72701308, 72701309, 72701269, 72701268, 40, 41, 44, 45, 39, 37, 15, 13, 7, 5, 4, 1, 0]])