hats.pixel_tree.pixel_alignment#

Attributes#

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

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

Module Contents#

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: hats.pixel_tree.pixel_tree.PixelTree, pixel_mapping: pandas.DataFrame, alignment_type: hats.pixel_tree.pixel_alignment_types.PixelAlignmentType, moc: mocpy.MOC = None)[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

Attributes:
pixel_treePixelTree

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_mappingpd.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_typePixelAlignmentType

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]#
pixel_tree[source]#
pixel_mapping[source]#
alignment_type[source]#
moc = None[source]#
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[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:
leftPixelTree

The left tree to align

rightPixelTree

The right tree to align

alignment_typePixelAlignmentType

(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

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:
mappingnp.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_orderint

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,

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:
leftnp.ndarray

the left array of intervals

rightnp.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]

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:
leftnp.ndarray

the left array of intervals

rightnp.ndarray

the right array of intervals

include_all_leftbool

if all pixels from the left tree should be covered in the final alignment

include_all_rightbool

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:
alignmentPixelAlignment

The pixel alignment to filter

mocmocpy.MOC

The moc to filter by

Returns:
PixelAlignment

PixelAlignment object with the filtered mapping and tree

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[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_treePixelTree

The left tree to align

right_treePixelTree

The right tree to align

left_mocmocpy.MOC

the moc with the coverage of the left catalog

right_mocmocpy.MOC

the moc with the coverage of the right catalog

alignment_typePixelAlignmentType

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.