uniform_grid_fromintv

odl.discr.grid.uniform_grid_fromintv(intv_prod, shape, nodes_on_bdry=True)[source]

Return a grid from sampling an interval product uniformly.

The resulting grid will by default include intv_prod.min_pt and intv_prod.max_pt as grid points. If you want a subdivision into equally sized cells with grid points in the middle, use uniform_partition instead.

Parameters
intv_prodIntervalProd

Set to be sampled.

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
samplingRectGrid

Uniform sampling grid for the interval product.

See also

uniform_grid

Create a uniform grid directly.

odl.discr.partition.uniform_partition_fromintv

divide interval product into equally sized subsets

Examples

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

To have the nodes in the “middle”, use nodes_on_bdry=False:

>>> grid = uniform_grid_fromintv(rbox, (2, 2), nodes_on_bdry=False)
>>> grid.coord_vectors
(array([-1.25, -0.75]), array([ 2.25,  2.75]))