hats.pixel_math.spatial_index#

Attributes#

Functions#

compute_spatial_index(→ numpy.ndarray)

Compute the healpix index field.

spatial_index_to_healpix(→ numpy.ndarray)

Convert healpix index values to the healpix pixel at the specified order

healpix_to_spatial_index(→ numpy.int64 | numpy.ndarray)

Convert a healpix pixel to the healpix index

Module Contents#

SPATIAL_INDEX_COLUMN = '_healpix_29'[source]#
SPATIAL_INDEX_ORDER = 29[source]#
compute_spatial_index(ra_values: float | list[float], dec_values: float | list[float], spatial_index_order: int = SPATIAL_INDEX_ORDER) numpy.ndarray[source]#

Compute the healpix index field.

Parameters:
ra_valuesfloat | list[float]

celestial coordinates, right ascension in degrees

dec_valuesfloat | list[float]

celestial coordinates, declination in degrees

spatial_index_order: int

(Default value = SPATIAL_INDEX_ORDER = 29) order to use for spatial index

Returns:
np.ndarray

HEALPix pixel indices at specified order, for all coordinates provided.

Raises:
ValueError

if the length of the input lists don’t match.

spatial_index_to_healpix(ids: list[int], target_order: int = SPATIAL_INDEX_ORDER, spatial_index_order: int = SPATIAL_INDEX_ORDER) numpy.ndarray[source]#

Convert healpix index values to the healpix pixel at the specified order

Parameters:
idslist[int]

list of well-formatted _healpix_29 values

target_orderint

Defaults to SPATIAL_INDEX_ORDER. The order of the pixel to get from the healpix index.

spatial_index_order: int

(Default value = SPATIAL_INDEX_ORDER = 29) order to use for spatial index

Returns:
np.ndarray

numpy array of target_order pixels from the healpix index

healpix_to_spatial_index(order: int | list[int], pixel: int | list[int], spatial_index_order: int = SPATIAL_INDEX_ORDER) numpy.int64 | numpy.ndarray[source]#

Convert a healpix pixel to the healpix index

This maps the healpix pixel to the lowest pixel number within that pixel at the specified healpix order.

Useful for operations such as filtering by _healpix_29.

Parameters:
orderint | list[int]

order of pixel to convert

pixelint | list[int]

pixel number in nested ordering of pixel to convert

spatial_index_order: int

(Default value = SPATIAL_INDEX_ORDER = 29) order to use for spatial index

Returns:
np.int64 | np.ndarray

healpix index or numpy array of healpix indices