uniform_partition_fromgrid¶
- odl.discr.partition.uniform_partition_fromgrid(grid, min_pt=None, max_pt=None)[source]¶
Return a partition of an interval product based on a given grid.
This method is complementary to
uniform_partition_fromintv
in that it infers the set to be partitioned from a given grid and optional parameters formin_pt
andmax_pt
of the set.- Parameters:
- grid
RectGrid
Grid on which the partition is based
- min_pt, max_ptfloat, sequence of floats, or dict, optional
Spatial points defining the lower/upper limits of the intervals to be partitioned. The points can be specified in two ways:
float or sequence: The values are used directly as
min_pt
and/ormax_pt
.dict: Index-value pairs specifying an axis and a spatial coordinate to be used in that axis. In axes which are not a key in the dictionary, the coordinate for the vector is calculated as:
min_pt = x[0] - (x[1] - x[0]) / 2 max_pt = x[-1] + (x[-1] - x[-2]) / 2
See
Examples
below.In general,
min_pt
may not be larger thangrid.min_pt
, andmax_pt
not smaller thangrid.max_pt
in any component.None
is equivalent to an empty dictionary, i.e. the values are calculated in each dimension.
- grid
See also
Examples
Have
min_pt
andmax_pt
of the bounding box automatically calculated:>>> grid = odl.uniform_grid(0, 1, 3) >>> grid.coord_vectors (array([ 0. , 0.5, 1. ]),) >>> part = odl.uniform_partition_fromgrid(grid) >>> part.cell_boundary_vecs (array([-0.25, 0.25, 0.75, 1.25]),)
min_pt
andmax_pt
can be given explicitly:>>> part = odl.uniform_partition_fromgrid(grid, min_pt=0, max_pt=1) >>> part.cell_boundary_vecs (array([ 0. , 0.25, 0.75, 1. ]),)
Using dictionaries, selective axes can be explicitly set. The keys refer to axes, the values to the coordinates to use:
>>> grid = odl.uniform_grid([0, 0], [1, 1], (3, 3)) >>> part = odl.uniform_partition_fromgrid(grid, ... min_pt={0: -1}, max_pt={-1: 3}) >>> part.cell_boundary_vecs[0] array([-1. , 0.25, 0.75, 1.25]) >>> part.cell_boundary_vecs[1] array([-0.25, 0.25, 0.75, 3. ])