covmats.get_pts_coords_regular_grid#

covmats.get_pts_coords_regular_grid(mesh_dim: float | Sequence[float] | ndarray[tuple[Any, ...], dtype[floating]], shape: int | Sequence[int] | ndarray[tuple[Any, ...], dtype[integer]]) → ndarray[tuple[Any, ...], dtype[floating]][source]#

Create an array of points coordinates for regular grids.

It supports from 1 to n dimensions.

Parameters:
  • mesh_dim (Union[float, Sequence[float], NDArrayFloat]) – Dimensions of one mesh (grid cell) of the grid, one value per spatial dimension. A single scalar can be given for an isotropic mesh: it is then broadcast to all dimensions of shape.

  • shape (Union[int, Sequence[int], NDArrayInt]) – Shape of the grid (number of grid cells along each axis). If mesh_dim has more than one element, the number of elements in shape must match the number of elements in mesh_dim.

Returns:

Array of coordinates with shape (Npts, Ndims), Npts being the total number of grid points (the product of shape) and Ndims the number of spatial dimensions (the size of shape).

Return type:

NDArrayFloat

Raises:

ValueError – If mesh_dim has more than one element and its size does not match the size of shape.

Examples

>>> import numpy as np
>>> from covmats import get_pts_coords_regular_grid
>>> get_pts_coords_regular_grid(mesh_dim=1.0, shape=(2, 2))
array([[0.5, 0.5],
       [1.5, 0.5],
       [0.5, 1.5],
       [1.5, 1.5]])
>>> get_pts_coords_regular_grid(mesh_dim=[1.0, 2.0], shape=(2, 2)).shape
(4, 2)