xoa.core.mask.polygon_mask

Contents

xoa.core.mask.polygon_mask#

xoa.core.mask.polygon_mask(poly, lon, lat, lon_bounds=None, lat_bounds=None, threshold=0.5)[source]#

Mask of the grid cells that are inside a polygon

A cell is inside when the fraction of its area covered by the polygon, as computed by polygon_cell_fraction(), is at least threshold.

Parameters:
  • poly (array_like(n, 2)) – Vertices of the polygon as (lon, lat) pairs in degrees

  • lon (array_like(ny, nx)) – Longitudes and latitudes of the cell centers

  • lat (array_like(ny, nx)) – Longitudes and latitudes of the cell centers

  • lon_bounds (array_like(ny, nx, 4), None) – Longitudes and latitudes of the cell corners. When not provided, a cell is inside when its center is.

  • lat_bounds (array_like(ny, nx, 4), None) – Longitudes and latitudes of the cell corners. When not provided, a cell is inside when its center is.

  • threshold (float) – Minimal covered fraction between 0 and 1, which is ignored without bounds. A null threshold selects all the cells that touch the polygon.

Returns:

array(bool) – Shape of lon