polygonContains

lsst.ts.wep.utils.polygonContains(xGrid: ndarray, yGrid: ndarray, poly: ndarray) ndarray

Return mask indicating if each point in the grid is inside the polygon.

Note this function works only in 2D, and assumes that xGrid and yGrid are regular grids like will be returned from np.meshgrid().

Parameters

xGridnp.ndarray

A 2D array of x values for the grid points. Must be floats.

yGridnp.ndarray

A 2D array of y values for the grid points. Must be floats.

polynp.ndarray

An Nx2 array of points specifying the polygon vertices. It is assumed that an edge connects every pair of adjacent points, and that the final point is identical to the first point. Must be floats.

Returns

np.ndarray

A 2D array with the same shape as xGrid and yGrid, indicating whether each point is inside the polygon

Raises

ValueError

If xGrid and yGrid are not the same shape, if either xGrid or yGrid are not 2D, or if poly is not an Nx2 array