Registration

class ctapointing.imagesolver.Registration(spot_list, star_list)

Bases: object

Registration class. Used to find matches between spot quads and star quads, using quad similarities.

Implements the following registration algorithms: (1) A search for best-matching quads based on geometric properties of the quads/ (2) A similarity transformation for selected quads that determines the rough

transformation between star and spot coordinates for these quads

  1. A matching algorithm that can match further stars to spots, using the above similarity transform.

Furthermore, methods are implemented to select among chosen quads based on certain quad or transformation properties.

Methods Summary

build_quads(object_list[, object_status, ...])

Build (triangular) quads from each triplet of Star or Spot SkyCameraFrame coordinate pairs.

find_matches([radius])

Find matches between star Quad objects and Spot Quad objects, based on their geometric invariants.

get_quad_matches([status])

Return list of QuadMatch objects, matching status flag.

get_quad_matches_transformed([status])

Returns a copy of selected QuadMatch objects, in which all StarQuad coordinates have been transformed to the SkyCameraFrame according to the transformation parameters of the similarity transform carried out for this QuadMatch.

get_quads_spots([status])

Return list of Quad objects constructed from Spots, matching status flag.

get_quads_stars([status])

Return list of Quad objects constructed from Stars, matching status flag.

get_spots([status])

Return list of stored Spot objects, matching status flag.

get_stars([status])

Return list of stored Star objects, matching status flag.

preselect_by_scale([rtol])

From all primary QuadMatch objects, select those quad matches which match roughly in triangle circumference.

select_by_similarity([exp_rotation, ...])

Select QuadMatch objects based on their similarity transformation parameters.

similarity_transform([status])

Perform similarity transform between quads of stored QuadMatch objects.

Methods Documentation

static build_quads(object_list, object_status=<Status.USED: 1>, quad_name='')

Build (triangular) quads from each triplet of Star or Spot SkyCameraFrame coordinate pairs. With n objects given, exactly m = (n/3) “n choose 3” independent quads can be constructed. Quad information is composed of L2/L1 (the ratio of the largest and second-to-largest side lengths of the triangle), L1/L0 (the ratio of the second largest and smallest side lengths), as well as L2+L1+L0 (i.e. the circumference of the triangle).

Parameters:
  • object_list – list of Spot or Star objects used to build the quads

  • object_status – status flag that can be used to select a subset of the objects from object_list

  • quad_name – prefix used to name the individual spots

Returns quad_list:

list of all Quad objects built

find_matches(radius=0.1)

Find matches between star Quad objects and Spot Quad objects, based on their geometric invariants.

The algorithm uses nearest neighbour matching in the L2/L1 - L0/L1 plane of the geometric invariants. It uses an efficient kd tree with k=2 for searching through all spot quads and identifying all star quads that match in this plane within a circle of given radius.

Resulting quad matches are stored in the objects QuadMatch list.

Note: If the search plane is densely populated and/or the search radius is large, there may exist more than one star-quad match for any given spot quad. Naturally, for some spot quads, no matching star quad will be found.

Parameters:

radius – search radius for the kd tree search. All matches within this search radius will be returned.

get_quad_matches(status=<Status.DEFAULT: 0>)

Return list of QuadMatch objects, matching status flag.

get_quad_matches_transformed(status=<Status.SELECTED: 4>)

Returns a copy of selected QuadMatch objects, in which all StarQuad coordinates have been transformed to the SkyCameraFrame according to the transformation parameters of the similarity transform carried out for this QuadMatch.

Parameters:

status – status flag for QuadMatch selection: only QuadMatches with this status flag set will be evaluated

Returns:

list (deep copy) of transformed QuadMatch objects

get_quads_spots(status=<Status.DEFAULT: 0>)

Return list of Quad objects constructed from Spots, matching status flag.

get_quads_stars(status=<Status.DEFAULT: 0>)

Return list of Quad objects constructed from Stars, matching status flag.

get_spots(status=<Status.DEFAULT: 0>)

Return list of stored Spot objects, matching status flag.

get_stars(status=<Status.DEFAULT: 0>)

Return list of stored Star objects, matching status flag.

preselect_by_scale(rtol=0.02)

From all primary QuadMatch objects, select those quad matches which match roughly in triangle circumference. This will reduce the number of false-positive quad matches quite a bit.

The selection is motivated by the fact that the focal length of the camera is a usually well-known constant. If chosen appropriately, star quads transformed into the SkyCameraFrame will have roughly the same circumference as spot quads.

Selected QuadMatch objects will obtain the status PRESELECTED.

Parameters:

rtol – maximum accepted relative tolerance between the circumference of star and spot quads used for selection.

select_by_similarity(exp_rotation=(<Quantity 0. deg>, <Quantity 5. deg>), exp_scale=(1.0, 0.1), tolerance=2.0, status=<Status.PRESELECTED: 2>)

Select QuadMatch objects based on their similarity transformation parameters.

(1) Perform a similarity transformation on all matched quad pairs, resulting in a set of four transformation parameters for each match: - rotation of star quad w.r.t. spot quad - scaling of star quad w.r.t. spot quad - offsets (x, y) between star quad and spot quads.

(2) Create a histogram of each parameter. We expect a smooth distribution in the parameter for falsely matched quads, and a narrow peak for those quad matches that are correctly matched.

(3) Find the peak in each of the parameter distributions, and select, based on the peak width and the tolerance argument, all quad matches closely around the peak.

  1. Accept all quad matches which pass selection in all parameters.

Selected QuadMatch objects will be marked with status SELECTED.

Parameters:
  • exp_rotation – tuple of Angle expected relative rotation between fitted star and spot quads and maximum tolerance (usually 0.0 deg, 10.0 deg)

  • exp_scale – tuple of float expected scaling between fitted star and spot quads and maximum tolerance (usually 1.0, 0.1)

  • tolerance – relative tolerance for cut around the peak. Set to None to disable the automatic procedure

and instead use the expected parameter ranges given as arguments

similarity_transform(status=<Status.PRESELECTED: 2>)

Perform similarity transform between quads of stored QuadMatch objects.

For the similarity transform, scale, rotation and two offsets are fitted between the star quad and the spot quad of each QuadMatch object.

Transformation parameters are stored in the transformation_properties attribute of the QuadMatch object.

The status of the QuadMatch is set to SIMFITTED.

Parameters:

status – status flag for QuadMatch selection: only QuadMatches with this status flag set will be evaluated

__init__(spot_list, star_list)

Constructor.

Parameters:
  • spot_list – list of Spot objects used in the primary quad matching.

  • star_list – list of Star objects used in the primary quad matching.

static build_quads(object_list, object_status=<Status.USED: 1>, quad_name='')

Build (triangular) quads from each triplet of Star or Spot SkyCameraFrame coordinate pairs. With n objects given, exactly m = (n/3) “n choose 3” independent quads can be constructed. Quad information is composed of L2/L1 (the ratio of the largest and second-to-largest side lengths of the triangle), L1/L0 (the ratio of the second largest and smallest side lengths), as well as L2+L1+L0 (i.e. the circumference of the triangle).

Parameters:
  • object_list – list of Spot or Star objects used to build the quads

  • object_status – status flag that can be used to select a subset of the objects from object_list

  • quad_name – prefix used to name the individual spots

Returns quad_list:

list of all Quad objects built

find_matches(radius=0.1)

Find matches between star Quad objects and Spot Quad objects, based on their geometric invariants.

The algorithm uses nearest neighbour matching in the L2/L1 - L0/L1 plane of the geometric invariants. It uses an efficient kd tree with k=2 for searching through all spot quads and identifying all star quads that match in this plane within a circle of given radius.

Resulting quad matches are stored in the objects QuadMatch list.

Note: If the search plane is densely populated and/or the search radius is large, there may exist more than one star-quad match for any given spot quad. Naturally, for some spot quads, no matching star quad will be found.

Parameters:

radius – search radius for the kd tree search. All matches within this search radius will be returned.

get_quad_matches(status=<Status.DEFAULT: 0>)

Return list of QuadMatch objects, matching status flag.

get_quad_matches_transformed(status=<Status.SELECTED: 4>)

Returns a copy of selected QuadMatch objects, in which all StarQuad coordinates have been transformed to the SkyCameraFrame according to the transformation parameters of the similarity transform carried out for this QuadMatch.

Parameters:

status – status flag for QuadMatch selection: only QuadMatches with this status flag set will be evaluated

Returns:

list (deep copy) of transformed QuadMatch objects

get_quads_spots(status=<Status.DEFAULT: 0>)

Return list of Quad objects constructed from Spots, matching status flag.

get_quads_stars(status=<Status.DEFAULT: 0>)

Return list of Quad objects constructed from Stars, matching status flag.

get_spots(status=<Status.DEFAULT: 0>)

Return list of stored Spot objects, matching status flag.

get_stars(status=<Status.DEFAULT: 0>)

Return list of stored Star objects, matching status flag.

preselect_by_scale(rtol=0.02)

From all primary QuadMatch objects, select those quad matches which match roughly in triangle circumference. This will reduce the number of false-positive quad matches quite a bit.

The selection is motivated by the fact that the focal length of the camera is a usually well-known constant. If chosen appropriately, star quads transformed into the SkyCameraFrame will have roughly the same circumference as spot quads.

Selected QuadMatch objects will obtain the status PRESELECTED.

Parameters:

rtol – maximum accepted relative tolerance between the circumference of star and spot quads used for selection.

select_by_similarity(exp_rotation=(<Quantity 0. deg>, <Quantity 5. deg>), exp_scale=(1.0, 0.1), tolerance=2.0, status=<Status.PRESELECTED: 2>)

Select QuadMatch objects based on their similarity transformation parameters.

(1) Perform a similarity transformation on all matched quad pairs, resulting in a set of four transformation parameters for each match: - rotation of star quad w.r.t. spot quad - scaling of star quad w.r.t. spot quad - offsets (x, y) between star quad and spot quads.

(2) Create a histogram of each parameter. We expect a smooth distribution in the parameter for falsely matched quads, and a narrow peak for those quad matches that are correctly matched.

(3) Find the peak in each of the parameter distributions, and select, based on the peak width and the tolerance argument, all quad matches closely around the peak.

  1. Accept all quad matches which pass selection in all parameters.

Selected QuadMatch objects will be marked with status SELECTED.

Parameters:
  • exp_rotation – tuple of Angle expected relative rotation between fitted star and spot quads and maximum tolerance (usually 0.0 deg, 10.0 deg)

  • exp_scale – tuple of float expected scaling between fitted star and spot quads and maximum tolerance (usually 1.0, 0.1)

  • tolerance – relative tolerance for cut around the peak. Set to None to disable the automatic procedure

and instead use the expected parameter ranges given as arguments

similarity_transform(status=<Status.PRESELECTED: 2>)

Perform similarity transform between quads of stored QuadMatch objects.

For the similarity transform, scale, rotation and two offsets are fitted between the star quad and the spot quad of each QuadMatch object.

Transformation parameters are stored in the transformation_properties attribute of the QuadMatch object.

The status of the QuadMatch is set to SIMFITTED.

Parameters:

status – status flag for QuadMatch selection: only QuadMatches with this status flag set will be evaluated