hipscat.pixel_tree.pixel_alignment#

Module Contents#

Classes#

PixelAlignment

Represents how two pixel trees align with each other, meaning which pixels match

Functions#

align_trees(→ PixelAlignment)

Generate a PixelAlignment object from two pixel trees

get_pixel_mapping_df(→ pandas.DataFrame)

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

perform_inner_align_trees(→ numpy.ndarray)

Performs an inner alignment on arrays of pixel intervals

_add_pixels_until(add_from, add_to, matching_pix, ...)

Adds pixels of the greatest possible order to fill output from add-from to add_to

_add_remaining_pixels(added_until, pixel_list, index, ...)

Adds pixels to output and mapping from a given index in a list of pixel intervals

perform_align_trees(→ List[numpy.ndarray])

Performs an alignment on arrays of pixel intervals

filter_alignment_by_moc(→ PixelAlignment)

Filters an alignment by a moc to only include pixels in the aligned_tree that overlap with the moc,

align_with_mocs(→ PixelAlignment)

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

Attributes#

LEFT_INCLUDE_ALIGNMENT_TYPES

RIGHT_INCLUDE_ALIGNMENT_TYPES

NONE_PIX

LEFT_SIDE

RIGHT_SIDE

LEFT_INCLUDE_ALIGNMENT_TYPES[source]#
RIGHT_INCLUDE_ALIGNMENT_TYPES[source]#
NONE_PIX[source]#
LEFT_SIDE = True[source]#
RIGHT_SIDE = False[source]#
class PixelAlignment(aligned_tree: hipscat.pixel_tree.pixel_tree.PixelTree, pixel_mapping: pandas.DataFrame, alignment_type: hipscat.pixel_tree.pixel_alignment_types.PixelAlignmentType)[source]#

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

pixel_mapping#

A dataframe where each row contains a pixel from each tree that match, and which pixel in the aligned tree they match with

pixel_tree#

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.

alignment_type#

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

PRIMARY_ORDER_COLUMN_NAME = 'primary_Norder'[source]#
PRIMARY_PIXEL_COLUMN_NAME = 'primary_Npix'[source]#
JOIN_ORDER_COLUMN_NAME = 'join_Norder'[source]#
JOIN_PIXEL_COLUMN_NAME = 'join_Npix'[source]#
ALIGNED_ORDER_COLUMN_NAME = 'aligned_Norder'[source]#
ALIGNED_PIXEL_COLUMN_NAME = 'aligned_Npix'[source]#
align_trees(left: hipscat.pixel_tree.pixel_tree.PixelTree, right: hipscat.pixel_tree.pixel_tree.PixelTree, alignment_type: hipscat.pixel_tree.pixel_alignment_types.PixelAlignmentType = PixelAlignmentType.INNER) PixelAlignment[source]#

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 – The left tree to align

  • right – The right tree to align

  • alignment_type

    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:

The PixelAlignment object with the alignment from the two trees

get_pixel_mapping_df(mapping: numpy.ndarray, map_order: int) pandas.DataFrame[source]#

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:

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

perform_inner_align_trees(left: numpy.ndarray, right: numpy.ndarray) numpy.ndarray[source]#

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 (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]

_add_pixels_until(add_from: int, add_to: int, matching_pix: numpy.ndarray, is_left_pixel: bool, mapping: List[numpy.ndarray])[source]#

Adds pixels of the greatest possible order to fill output from add-from to add_to

Adds these pixels to the mapping as the aligned pixel, with matching pix added as either the left or right side of the mapping and none pixel for the other.

Parameters:
  • add_from (int) – The pixel number to add pixels from

  • add_to (int) – The pixel number to add pixels to

  • matching_pix (int) – The matching pixel from the side of the catalog that exists to map the new pixels to in the mapping

  • is_left_pixel (int) – Is the matching pixel from the left side of the alignment

  • mapping (List[np.ndarray]) – The List mapping left, right, and aligned pixels to add the new pixels to

_add_remaining_pixels(added_until: int, pixel_list: numpy.ndarray, index: int, is_left_pixel: bool, mapping: List[numpy.ndarray])[source]#

Adds pixels to output and mapping from a given index in a list of pixel intervals

Parameters:
  • added_until (int) – Where the alignment has been added until

  • pixel_list (np.ndarray) – The list of pixels from the side of the alignment to add the remaining pixels of

  • index (int) – The index of the pixel list to add the pixels from

  • is_left_pixel (bool) – Is the pixel list from left side of the alignment

  • mapping (List[np.ndarray]) – The List mapping left, right, and aligned pixels to add the new pixels to

perform_align_trees(left: numpy.ndarray, right: numpy.ndarray, include_all_left: bool, include_all_right: bool) List[numpy.ndarray][source]#

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]

filter_alignment_by_moc(alignment: PixelAlignment, moc: mocpy.MOC) PixelAlignment[source]#

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 object with the filtered mapping and tree

align_with_mocs(left_tree: hipscat.pixel_tree.pixel_tree.PixelTree, right_tree: hipscat.pixel_tree.pixel_tree.PixelTree, left_moc: mocpy.MOC | None, right_moc: mocpy.MOC | None, alignment_type: hipscat.pixel_tree.pixel_alignment_types.PixelAlignmentType = PixelAlignmentType.INNER) PixelAlignment[source]#

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:

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