API Reference#

Tools for polygonal paving, transfer matrices, and rectilinear grids.

quickpaver provides utilities to generate polygonal tilings, manipulate rectilinear grids, compute transfer matrices between geometries, and load simple geographical test contours. The package is designed around cell-based geometry: tiles, polygons, and grid cells are represented explicitly and can be combined with NumPy arrays, Shapely geometries, and sparse SciPy matrices.

The public API is grouped into four main areas:

  • polygon and tiling generation;

  • transfer-matrix construction;

  • geographical test contours;

  • rectilinear-grid utilities.

Polygon helpers#

Utilities for creating base polygons and describing supported tile types.

PolygonType(value)

Polygon types.

gen_polygon(poly_type[, edge_length, ...])

Generate a reference polygon centred at the origin.

Tiling functions#

Functions to generate polygonal tilings over a target surface. Supported tile families include rectangles, triangles, and hexagons. Tiling generators return both the generated polygons and adjacency information between kept tiles.

gen_hexagonal_tiling(surface_to_cover, ...)

Create a grid of hexagons within the given bounding box.

gen_rectangular_tiling(surface_to_cover, ...)

Create a grid of hexagons within the given bounding box.

gen_triangular_tiling(surface_to_cover, ...)

Generate a triangular tiling covering a given surface.

gen_polygonal_tiling(surface_to_cover, ...)

Cover the given surface with tiles (polygons) of the desired type.

extract_tiling_centers(polygons)

Extract the centers of each tile (polygon).

extract_tiling_vertices(polygons[, n_decimals])

Extract the vertices of all polygons (without duplicates).

Transfer matrices#

Utilities to compute sparse transfer matrices between source and target geometries.

compute_transfer_matrix(source_grid, target_grid)

Build a conservative transfer matrix between two polygonal grids.

Test data#

Convenience functions providing geographical contours useful for examples, tests, and demonstrations.

Regular grids#

Classes and utilities for working with cell-based rectilinear grids. These functions cover grid indexing, sparse neighbour operators, polygon selections, binary dilation, resampling, and conservative or duplicative array upsampling.

Grid()

Define a grid.

RectilinearGrid([cx, cy, cz, dx, dy, dz, ...])

Represent a rectilinear 3D grid.

rlg_idx_to_nn(ix[, nx, iy, ny, iz, ...])

Convert indices (ix, iy, iz) to a node-number.

rlg_nn_to_idx(node_number[, nx, ny, ...])

Convert a node-number to indices (ix, iy, iz) for a regular grid.

span_to_node_numbers_2d(span, nx, ny)

Convert a 2D grid span to flattened node numbers.

span_to_node_numbers_3d(span, nx, ny, nz)

Convert a 3D grid span to flattened node numbers.

get_array_borders_selection(nx, ny)

Get a selection of the array border as a bool array.

get_owner_neigh_indices(grid, span_owner, ...)

Return paired owner and neighbour flattened grid-cell indices.

get_rlg_spatial_grad_mat(grid, n, axis, ...)

Build a sparse spatial-gradient matrix along one grid axis.

make_rlg_spatial_gradient_matrices(grid[, ...])

Build sparse spatial-gradient matrices for a rectilinear grid.

get_rlg_perm_mat(grid, n, axis, sub_selection)

Build a sparse forward-neighbour permutation matrix along one grid axis.

make_rlg_spatial_permutation_matrices(grid)

Make matrices to compute the spatial permutations along x and y axes of a field.

create_selections_array_2d(polygons, ...)

Return a grid array containing the sel_ids as values.

get_polygon_selection_with_dilation_2d(...)

Extend the selections using binary dilation.

get_polygon_selection_with_dilation_3d(...)

Extend the selections using binary dilation.

binary_dilation(seed_mask, domain_mask[, ...])

Dilate a 2D boolean array within a constrained domain.

resample_grid(original_grid, factor_x, ...)

Resample a rectilinear grid by changing the number of cells along each axis.

duplicative_upsample(array, factor)

Upsample a 2D array by duplicating each cell value.

conservative_upsample(array, factor)

Upsample a 2D extensive array while preserving its total sum.