eloy.alignment#

Alignment utilities for astronomical image processing.

This module provides functions for matching, aligning, and transforming coordinate sets, including cross-matching, reference asterism generation, and rotation matrix calculation using the twirl package.

Functions#

cross_match(S1, S2[, tolerance, return_idxs, none])

Matches points from two sets of points based on proximity.

twirl_reference(coords)

Creates a cKDTree and stores asterisms for reference coordinates.

rotation_matrix(coords, ref_coords, reference[, ...])

Calculates a rotation matrix aligning two sets of coordinates.

Module Contents#

eloy.alignment.cross_match(S1, S2, tolerance=10, return_idxs=False, none=True)[source]#

Matches points from two sets of points based on proximity.

Parameters:
  • S1 (numpy.ndarray) – A 2D array where each row represents a point in the first set.

  • S2 (numpy.ndarray) – A 2D array where each row represents a point in the second set.

  • tolerance (float, optional) – The maximum distance for a point to be considered a match. Defaults to 10.

  • return_idxs (bool, optional) – If True, returns the indices of the matched points. Defaults to False.

  • none (bool, optional) – If True, appends a NaN value for unmatched points in S1. Defaults to True.

Returns:

If return_idxs is True, returns a 2D array of indices. Otherwise, returns two 2D arrays of matched points from S1 and S2, respectively. If no matches are found, returns empty arrays.

Return type:

numpy.ndarray

eloy.alignment.twirl_reference(coords)[source]#

Creates a cKDTree and stores asterisms for reference coordinates.

Parameters:

coords (numpy.ndarray) – A 2D array of reference coordinates.

Returns:

Tuple (cKDTree, numpy.ndarray) containing the tree and asterisms.

Return type:

tuple

eloy.alignment.rotation_matrix(coords, ref_coords, reference, tolerance=2, refine=True, rtol=0.02)[source]#

Calculates a rotation matrix aligning two sets of coordinates.

Parameters:
  • coords (numpy.ndarray) – A 2D array of coordinates to be aligned.

  • ref_coords (numpy.ndarray) – A 2D array of reference coordinates.

  • reference (tuple) – Tuple (cKDTree, numpy.ndarray) for the reference coordinates.

  • tolerance (float, optional) – Tolerance for matching points.

  • refine (bool, optional) – Whether to refine the rotation matrix.

  • rtol (float, optional) – Relative tolerance for the cKDTree query.

Returns:

A 3x3 numpy array representing the rotation matrix, or None if no matches are found.

Return type:

numpy.ndarray or None