uniform_grid

odl.discr.grid.uniform_grid(min_pt, max_pt, shape, nodes_on_bdry=True)[source]

Return a grid from sampling an implicit interval product uniformly.

Parameters
min_ptfloat or sequence of float

Vectors of lower ends of the intervals in the product.

max_ptfloat or sequence of float

Vectors of upper ends of the intervals in the product.

shapeint or sequence of ints

Number of nodes per axis. Entries corresponding to degenerate axes must be equal to 1.

nodes_on_bdrybool or sequence, optional

If a sequence is provided, it determines per axis whether to place the last grid point on the boundary (True) or shift it by half a cell size into the interior (False). In each axis, an entry may consist in a single bool or a 2-tuple of bool. In the latter case, the first tuple entry decides for the left, the second for the right boundary. The length of the sequence must be array.ndim.

A single boolean is interpreted as a global choice for all boundaries.

Returns
uniform_gridRectGrid

The resulting uniform grid.

See also

uniform_grid_fromintv

sample a given interval product

odl.discr.partition.uniform_partition

divide implicitly defined interval product into equally sized subsets

Examples

By default, the min/max points are included in the grid:

>>> grid = odl.uniform_grid([-1.5, 2], [-0.5, 3], (3, 3))
>>> grid.coord_vectors
(array([-1.5, -1. , -0.5]), array([ 2. ,  2.5,  3. ]))

If shape is supposed to refer to small subvolumes, and the grid should be their centers, use the option nodes_on_bdry=False:

>>> grid = odl.uniform_grid([-1.5, 2], [-0.5, 3], (2, 2),
...                         nodes_on_bdry=False)
>>> grid.coord_vectors
(array([-1.25, -0.75]), array([ 2.25,  2.75]))

In 1D, we don’t need sequences:

>>> grid = odl.uniform_grid(0, 1, 3)
>>> grid.coord_vectors
(array([ 0. ,  0.5,  1. ]),)