hats.pixel_math.validators#

Classes#

ValidatorsErrors

Error messages for the coordinate validators

Functions#

validate_radius(radius_arcsec)

Validates that a cone search radius is positive

validate_declination_values(dec)

Validates that declination values are in the [-90,90] degree range

validate_polygon(vertices)

Checks if the polygon contain a minimum of three vertices, that they are

check_polygon_is_valid(vertices)

Check if the polygon has no degenerate corners and it is convex.

validate_box(ra, dec)

Checks if ra and dec values are valid for the box search.

Module Contents#

class ValidatorsErrors[source]#

Bases: str, enum.Enum

Error messages for the coordinate validators

INVALID_DEC = 'declination must be in the -90.0 to 90.0 degree range'[source]#
INVALID_RADIUS = 'cone radius must be positive'[source]#
INVALID_NUM_VERTICES = 'polygon must contain a minimum of 3 vertices'[source]#
DUPLICATE_VERTICES = 'polygon has duplicated vertices'[source]#
DEGENERATE_POLYGON = 'polygon is degenerate'[source]#
INVALID_RADEC_RANGE = 'invalid ra or dec range'[source]#
INVALID_COORDS_SHAPE = 'invalid coordinates shape'[source]#
INVALID_CONCAVE_SHAPE = 'polygon must be convex'[source]#
validate_radius(radius_arcsec: float)[source]#

Validates that a cone search radius is positive

Parameters:

radius_arcsec (float) – The cone radius, in arcseconds

Raises:

ValueError – if radius is non-positive

validate_declination_values(dec: float | list[float])[source]#

Validates that declination values are in the [-90,90] degree range

Parameters:

dec (float | List[float]) – The declination values to be validated

Raises:

ValueError – if declination values are not in the [-90,90] degree range

validate_polygon(vertices: list[tuple[float, float]])[source]#

Checks if the polygon contain a minimum of three vertices, that they are unique and that the polygon does not fall on a great circle.

Parameters:

vertices (list[tuple[float,float]]) – The list of vertice coordinates for the polygon, (ra, dec), in degrees.

Raises:

ValueError – exception if the polygon is invalid.

check_polygon_is_valid(vertices: numpy.ndarray)[source]#

Check if the polygon has no degenerate corners and it is convex.

Parameters:

vertices (np.ndarray) – The polygon vertices, in cartesian coordinates

validate_box(ra: tuple[float, float], dec: tuple[float, float])[source]#

Checks if ra and dec values are valid for the box search.

  • Both ranges for ra or dec must have been provided.

  • Ranges must be defined by a pair of values, in degrees.

  • Declination values must be unique, provided in ascending order, and

belong to the [-90,90] degree range.

Parameters:
  • ra (Tuple[float, float]) – Right ascension range, in degrees

  • dec (Tuple[float, float]) – Declination range, in degrees