uniform_partition_fromintv¶
-
odl.discr.partition.
uniform_partition_fromintv
(intv_prod, shape, nodes_on_bdry=False)[source]¶ Return a partition of an interval product into equally sized cells.
- Parameters
- intv_prod
IntervalProd
Interval product to be partitioned
- shapeint or sequence of ints
Number of nodes per axis. For 1d intervals, a single integer can be specified.
- 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 beintv_prod.ndim
.A single boolean is interpreted as a global choice for all boundaries.
- intv_prod
See also
Examples
By default, no grid points are placed on the boundary:
>>> interval = odl.IntervalProd(0, 1) >>> part = odl.uniform_partition_fromintv(interval, 4) >>> part.cell_boundary_vecs (array([ 0. , 0.25, 0.5 , 0.75, 1. ]),) >>> part.grid.coord_vectors (array([ 0.125, 0.375, 0.625, 0.875]),)
This can be changed with the nodes_on_bdry parameter:
>>> part = odl.uniform_partition_fromintv(interval, 3, ... nodes_on_bdry=True) >>> part.cell_boundary_vecs (array([ 0. , 0.25, 0.75, 1. ]),) >>> part.grid.coord_vectors (array([ 0. , 0.5, 1. ]),)
We can specify this per axis, too. In this case we choose both in the first axis and only the rightmost in the second:
>>> rect = odl.IntervalProd([0, 0], [1, 1]) >>> part = odl.uniform_partition_fromintv( ... rect, (3, 3), nodes_on_bdry=(True, (False, True))) ... >>> part.cell_boundary_vecs[0] # first axis, as above array([ 0. , 0.25, 0.75, 1. ]) >>> part.grid.coord_vectors[0] array([ 0. , 0.5, 1. ]) >>> part.cell_boundary_vecs[1] # second, asymmetric axis array([ 0. , 0.4, 0.8, 1. ]) >>> part.grid.coord_vectors[1] array([ 0.2, 0.6, 1. ])