hats.pixel_tree.pixel_alignment
===============================

.. py:module:: hats.pixel_tree.pixel_alignment


Attributes
----------

.. autoapisummary::

   hats.pixel_tree.pixel_alignment.LEFT_INCLUDE_ALIGNMENT_TYPES
   hats.pixel_tree.pixel_alignment.RIGHT_INCLUDE_ALIGNMENT_TYPES
   hats.pixel_tree.pixel_alignment.NONE_PIX
   hats.pixel_tree.pixel_alignment.LEFT_SIDE
   hats.pixel_tree.pixel_alignment.RIGHT_SIDE


Classes
-------

.. autoapisummary::

   hats.pixel_tree.pixel_alignment.PixelAlignment


Functions
---------

.. autoapisummary::

   hats.pixel_tree.pixel_alignment.align_trees
   hats.pixel_tree.pixel_alignment.get_pixel_mapping_df
   hats.pixel_tree.pixel_alignment.perform_inner_align_trees
   hats.pixel_tree.pixel_alignment.perform_align_trees
   hats.pixel_tree.pixel_alignment.filter_alignment_by_moc
   hats.pixel_tree.pixel_alignment.align_with_mocs


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

.. py:data:: LEFT_INCLUDE_ALIGNMENT_TYPES

.. py:data:: RIGHT_INCLUDE_ALIGNMENT_TYPES

.. py:data:: NONE_PIX

.. py:data:: LEFT_SIDE
   :value: True


.. py:data:: RIGHT_SIDE
   :value: False


.. py:class:: PixelAlignment(aligned_tree: hats.pixel_tree.pixel_tree.PixelTree, pixel_mapping: pandas.DataFrame, alignment_type: hats.pixel_tree.pixel_alignment_types.PixelAlignmentType, moc: mocpy.MOC = None)

   
   Represents how two pixel trees align with each other, meaning which pixels match
   or overlap between the catalogs, and a new tree with the smallest pixels from each tree

   For more information on the pixel alignment algorithm, view this document:
   https://docs.google.com/document/d/1gqb8qb3HiEhLGNav55LKKFlNjuusBIsDW7FdTkc5mJU/edit?usp=sharing


   :Attributes:

       **pixel_tree** : PixelTree
           The aligned tree generated by using the smallest pixels in each tree. For
           example, a tree with pixels at order 0, pixel 1, and a tree with order 1, pixel 4,5,6,
           and 7, would result in the smaller order 1 pixels in the aligned tree.

       **pixel_mapping** : pd.DataFrame
           A dataframe where each row contains a pixel from each tree that match, and
           which pixel in the aligned tree they match with

       **alignment_type** : PixelAlignmentType
           The type of alignment describing how to handle nodes which exist in one tree
           but not the other. Options are:
           
           - inner - only use pixels that appear in both catalogs
           - left - use all pixels that appear in the left catalog and any overlapping from the right
           - right - use all pixels that appear in the right catalog and any overlapping from the left
           - outer - use all pixels from both catalogs













   ..
       !! processed by numpydoc !!

   .. py:attribute:: PRIMARY_ORDER_COLUMN_NAME
      :value: 'primary_Norder'



   .. py:attribute:: PRIMARY_PIXEL_COLUMN_NAME
      :value: 'primary_Npix'



   .. py:attribute:: JOIN_ORDER_COLUMN_NAME
      :value: 'join_Norder'



   .. py:attribute:: JOIN_PIXEL_COLUMN_NAME
      :value: 'join_Npix'



   .. py:attribute:: ALIGNED_ORDER_COLUMN_NAME
      :value: 'aligned_Norder'



   .. py:attribute:: ALIGNED_PIXEL_COLUMN_NAME
      :value: 'aligned_Npix'



   .. py:attribute:: pixel_tree


   .. py:attribute:: pixel_mapping


   .. py:attribute:: alignment_type


   .. py:attribute:: moc
      :value: None



.. py:function:: align_trees(left: hats.pixel_tree.pixel_tree.PixelTree, right: hats.pixel_tree.pixel_tree.PixelTree, alignment_type: hats.pixel_tree.pixel_alignment_types.PixelAlignmentType = PixelAlignmentType.INNER) -> PixelAlignment

   
   Generate a `PixelAlignment` object from two pixel trees

   A `PixelAlignment` represents how two pixel trees align with each other, meaning which pixels
   match or overlap between the catalogs, and includes a new tree with the smallest pixels from
   each tree

   For more information on the pixel alignment algorithm, view this document:
   https://docs.google.com/document/d/1gqb8qb3HiEhLGNav55LKKFlNjuusBIsDW7FdTkc5mJU/edit?usp=sharing

   :Parameters:

       **left** : PixelTree
           The left tree to align

       **right** : PixelTree
           The right tree to align

       **alignment_type** : PixelAlignmentType
           (Default value = PixelAlignmentType.INNER)
           The type of alignment describing how to handle nodes which exist in one tree
           but not the other. Options are:
           
           - inner - only use pixels that appear in both catalogs
           - left - use all pixels that appear in the left catalog and any overlapping from the right
           - right - use all pixels that appear in the right catalog and any overlapping from the left
           - outer - use all pixels from both catalogs



   :Returns:

       PixelAlignment
           The `PixelAlignment` object with the alignment from the two trees











   ..
       !! processed by numpydoc !!

.. py:function:: get_pixel_mapping_df(mapping: numpy.ndarray, map_order: int) -> pandas.DataFrame

   
   Construct a DataFrame with HEALPix orders and pixels mapping left right and aligned pixels


   :Parameters:

       **mapping** : np.ndarray
           array of shape (6, len(aligned_pixels)) where the first two rows are the
           intervals for the left pixels, the next two for right pixels, and the last two for aligned pixels

       **map_order** : int
           The HEALPix order of the intervals in the mapping array



   :Returns:

       pd.DataFrame
           A DataFrame with the orders and pixels of the aligned left and right pixels,











   ..
       !! processed by numpydoc !!

.. py:function:: perform_inner_align_trees(left: numpy.ndarray, right: numpy.ndarray) -> numpy.ndarray

   
   Performs an inner alignment on arrays of pixel intervals

   Pixel interval lists must be of to the same order

   :Parameters:

       **left** : np.ndarray
           the left array of intervals

       **right** : np.ndarray
           the right array of intervals



   :Returns:

       np.ndarray
           The pixel mapping of the matching left, right, and aligned pixels with each row containing an array of
           [left_order, left_pixel, right_order, right_pixel, aligned_order, aligned_pixel]











   ..
       !! processed by numpydoc !!

.. py:function:: perform_align_trees(left: numpy.ndarray, right: numpy.ndarray, include_all_left: bool, include_all_right: bool) -> list[numpy.ndarray]

   
   Performs an alignment on arrays of pixel intervals

   Pixel interval lists must be of to the same order

   :Parameters:

       **left** : np.ndarray
           the left array of intervals

       **right** : np.ndarray
           the right array of intervals

       **include_all_left** : bool
           if all pixels from the left tree should be covered in the final alignment

       **include_all_right** : bool
           if all pixels from the right tree should be covered in the final alignment



   :Returns:

       list[np.ndarray]
           The pixel mapping of the matching left, right, and aligned pixels with each row containing an array of
           [left_order, left_pixel, right_order, right_pixel, aligned_order, aligned_pixel]











   ..
       !! processed by numpydoc !!

.. py:function:: filter_alignment_by_moc(alignment: PixelAlignment, moc: mocpy.MOC) -> PixelAlignment

   
   Filters an alignment by a moc to only include pixels in the aligned_tree that overlap with the moc,
   and the corresponding rows in the mapping.


   :Parameters:

       **alignment** : PixelAlignment
           The pixel alignment to filter

       **moc** : mocpy.MOC
           The moc to filter by



   :Returns:

       PixelAlignment
           PixelAlignment object with the filtered mapping and tree











   ..
       !! processed by numpydoc !!

.. py:function:: align_with_mocs(left_tree: hats.pixel_tree.pixel_tree.PixelTree, right_tree: hats.pixel_tree.pixel_tree.PixelTree, left_moc: mocpy.MOC | None, right_moc: mocpy.MOC | None, alignment_type: hats.pixel_tree.pixel_alignment_types.PixelAlignmentType = PixelAlignmentType.INNER) -> PixelAlignment

   
   Aligns two pixel trees and mocs together, resulting in a pixel alignment with only aligned pixels that
   have coverage in the mocs.


   :Parameters:

       **left_tree** : PixelTree
           The left tree to align

       **right_tree** : PixelTree
           The right tree to align

       **left_moc** : mocpy.MOC
           the moc with the coverage of the left catalog

       **right_moc** : mocpy.MOC
           the moc with the coverage of the right catalog

       **alignment_type** : PixelAlignmentType
           The type of alignment describing how to handle nodes which exist
           in one tree but not the other. Options are:
           
           - inner - only use pixels that appear in both catalogs
           - left - use all pixels that appear in the left catalog and any overlapping from the right
           - right - use all pixels that appear in the right catalog and any overlapping from the left
           - outer - use all pixels from both catalogs



   :Returns:

       PixelAlignment
           The PixelAlignment object with the aligned trees filtered by the coverage in the catalogs.











   ..
       !! processed by numpydoc !!

