hats.pixel_math.spatial_index
=============================

.. py:module:: hats.pixel_math.spatial_index


Attributes
----------

.. autoapisummary::

   hats.pixel_math.spatial_index.SPATIAL_INDEX_COLUMN
   hats.pixel_math.spatial_index.SPATIAL_INDEX_ORDER


Functions
---------

.. autoapisummary::

   hats.pixel_math.spatial_index.compute_spatial_index
   hats.pixel_math.spatial_index.spatial_index_to_healpix
   hats.pixel_math.spatial_index.healpix_to_spatial_index


Module Contents
---------------

.. py:data:: SPATIAL_INDEX_COLUMN
   :value: '_healpix_29'


.. py:data:: SPATIAL_INDEX_ORDER
   :value: 29


.. py:function:: compute_spatial_index(ra_values: float | list[float], dec_values: float | list[float], spatial_index_order: int = SPATIAL_INDEX_ORDER) -> numpy.ndarray

   
   Compute the healpix index field.


   :Parameters:

       **ra_values** : float | list[float]
           celestial coordinates, right ascension in degrees

       **dec_values** : float | 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.







   ..
       !! processed by numpydoc !!

.. py:function:: spatial_index_to_healpix(ids: list[int], target_order: int = SPATIAL_INDEX_ORDER, spatial_index_order: int = SPATIAL_INDEX_ORDER) -> numpy.ndarray

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


   :Parameters:

       **ids** : list[int]
           list of well-formatted _healpix_29 values

       **target_order** : int
           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











   ..
       !! processed by numpydoc !!

.. py:function:: healpix_to_spatial_index(order: int | list[int], pixel: int | list[int], spatial_index_order: int = SPATIAL_INDEX_ORDER) -> numpy.int64 | numpy.ndarray

   
   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:

       **order** : int | list[int]
           order of pixel to convert

       **pixel** : int | 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











   ..
       !! processed by numpydoc !!

