facet
Module that holds functions and classes related to faceting.
- lsmtool.facet.in_box(cal_coords, bounding_box)
Check if coordinates are inside the bounding box.
- Parameters:
cal_coords (
numpy.ndarray) – Array of x, y coordinates with shape (n, 2).bounding_box (
numpy.ndarray) – Array defining the bounding box as [minx, maxx, miny, maxy].
- Returns:
inside (
numpy.ndarray) – Boolean array with True for inside and False if not.
- lsmtool.facet.is_valid_region(region, vertices, bounding_box)
Check if a Voronoi region is valid by verifying all its vertices are within the bounding box.
- Parameters:
region (
listofint) – Indices of the vertices forming the region.vertices (
numpy.ndarray) – Array of vertex coordinates with shape (n, 2).bounding_box (
list) – Bounding box defined as [minx, maxx, miny, maxy].
- Returns:
bool – True if all vertices are inside the bounding box and the region is not empty, False otherwise.
- lsmtool.facet.prepare_points_for_tessellate(cal_coords, bounding_box)
Select calibration points inside the bounding box and generates mirrored points for Voronoi tessellation.
This function filters the input coordinates to those within the bounding box and creates mirrored points to ensure proper tessellation at the boundaries.
- Parameters:
cal_coords (
numpy.ndarray) – Array of x, y coordinates with shape (n, 2).bounding_box (
listornumpy.ndarray) – Array defining the bounding box as [minx, maxx, miny, maxy].
- Returns:
points_centre (
numpy.ndarray) – Calibration points inside the bounding box.points (
numpy.ndarray) – Array of calibration points and their mirrored counterparts for tessellation.
- lsmtool.facet.tessellate(
- directions,
- bbox_midpoint,
- bbox_size,
- wcs_pixel_scale=0.005555555555555556,
Make a Voronoi tessellation.
This function partitions an image region using Voronoi tessellation seeded with the input calibration directions. It filters points that fall outside the given dimensions of the bounding box and returns the facet centres and polygons that enscribe these points in celestial coordinates.
- Parameters:
directions (
astropy.coordinates.SkyCoord) – Coordinates of input calibration directions.bbox_midpoint (
astropy.coordinates.SkyCoord) – Coordinates of bounding box centre.bbox_size (
tupleoffloat) – Size of bounding box (RA, Dec). Should be a 2-tuple of numbers in degrees.wcs_pixel_scale (
float) – The pixel scale to use for the conversion to pixel coordinates in degrees per pixel.
- Returns:
facet_points (
numpy.ndarray) – Array of facet points centres with (RA, Dec) in degrees along the columns.facet_polys (
listofnumpy.ndarray) – Array of facet polygons (vertices) with (RA, Dec) in degrees along the columns (each array has shape (n, 2), where n is the number of vertices in a given facet).
- lsmtool.facet.voronoi(cal_coords, bounding_box, eps=1e-06)
Produce a Voronoi tessellation for the given coordinates and bounding box.
- Parameters:
cal_coords (
numpy.ndarray) – Array of x, y coordinates with shape (n, 2).bounding_box (
numpy.ndarray) – Array defining the bounding box as [minx, maxx, miny, maxy].eps (
float) – Numerical tolerance value, used to expand the bounding box slightly to avoid issues related to numeric precision.
- Returns:
points_centre (
numpy.ndarray) – Centre points of the Voronoi cells.vertices (
numpy.ndarray) – Vertices of the Voronoi grid. To obtain the vertices of the polygon that encloses any particular point, use the indices provided in the return value filtered_regions to select the corresponding vertices for a given cell.filtered_regions (
listoflistofint) – For each cell in the tesselation, a list of index points for the vertices that enclose the cell. For example vertices[filtered_regions[0]] are the vertices of the first cell. Only points that fall within the bounding_box are retained.