nonuniform_partition

odl.discr.partition.nonuniform_partition(\*coord_vecs, \*\*kwargs)[source]

Return a partition with un-equally sized cells.

Parameters
coord_vecs1, … coord_vecsNarray-like

Arrays of coordinates of the mid-points of the partition cells.

min_pt, max_ptfloat or sequence of floats, optional

Vectors defining the lower/upper limits of the intervals in an IntervalProd (a rectangular box). None entries mean “compute the value”.

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.

Cannot be given with both min_pt and max_pt since they determine the same thing.

Default: False

See also

uniform_partition

uniformly spaced points

uniform_partition_fromintv

partition an existing set

uniform_partition_fromgrid

use an existing grid as basis

Examples

With uniformly spaced points the result is the same as a uniform partition:

>>> odl.nonuniform_partition([0, 1, 2, 3])
uniform_partition(-0.5, 3.5, 4)
>>> odl.nonuniform_partition([0, 1, 2, 3], [1, 2])
uniform_partition([-0.5,  0.5], [ 3.5,  2.5], (4, 2))

If the points are not uniformly spaced, a nonuniform partition is created. Note that the containing interval is calculated by assuming that the points are in the middle of the sub-intervals:

>>> odl.nonuniform_partition([0, 1, 3])
nonuniform_partition(
    [ 0.,  1.,  3.]
)

Higher dimensional partitions are created by specifying the gridpoints along each dimension:

>>> odl.nonuniform_partition([0, 1, 3], [1, 2])
nonuniform_partition(
    [ 0.,  1.,  3.],
    [ 1.,  2.]
)

Partitions with a single element are by default degenerate

>>> odl.nonuniform_partition(1)
uniform_partition(1.0, 1.0, 1, nodes_on_bdry=True)

If the endpoints should be on the boundary, the nodes_on_bdry parameter can be used:

>>> odl.nonuniform_partition([0, 1, 3], nodes_on_bdry=True)
nonuniform_partition(
    [ 0.,  1.,  3.],
    nodes_on_bdry=True
)

Users can also manually specify the containing intervals dimensions by using the min_pt and max_pt arguments:

>>> odl.nonuniform_partition([0, 1, 3], min_pt=-2, max_pt=3)
nonuniform_partition(
    [ 0.,  1.,  3.],
    min_pt=-2.0, max_pt=3.0
)