uniform_discr_fromdiscr¶
-
odl.discr.discr_space.
uniform_discr_fromdiscr
(discr, min_pt=None, max_pt=None, shape=None, cell_sides=None, \*\*kwargs)[source]¶ Return a discretization based on an existing one.
The parameters that are explicitly given are used to create the new discretization, and the missing information is taken from the template space. See Notes for the exact functionality.
- Parameters
- discr
DiscretizedSpace
Uniformly discretized space used as a template.
- min_pt, max_pt: float or sequence of floats, optional
Desired minimum/maximum corners of the new space domain.
- shapeint or sequence of ints, optional
Desired number of samples per axis of the new space.
- cell_sidesfloat or sequence of floats, optional
Desired cell side lenghts of the new space’s partition.
- discr
- Other Parameters
- 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 bediscr.ndim
.A single boolean is interpreted as a global choice for all boundaries.
Default:
False
.- kwargs :
Additional keyword parameters passed to the
DiscretizedSpace
initializer.
See also
uniform_discr
implicit uniform Lp discretization
odl.discr.partition.uniform_partition
underlying domain partitioning scheme
Notes
The parameters
min_pt
,max_pt
,shape
andcell_sides
can be combined in the following ways (applies in each axis individually):- 0 arguments:
Return a copy of
discr
- 1 argument:
[min,max]_pt -> keep sampling but translate domain so it starts/ends at
[min,max]_pt
shape/cell_sides -> keep domain but change sampling. See
uniform_partition
for restrictions.- 2 arguments:
min_pt + max_pt -> translate and resample with the same number of samples
[min,max]_pt + shape/cell_sides -> translate and resample
shape + cell_sides -> error due to ambiguity (keep
min_pt
ormax_pt
?)- 3+ arguments:
The underlying partition is uniquely determined by the new parameters. See
uniform_partition
.
Examples
>>> discr = odl.uniform_discr([0, 0], [1, 2], (10, 5)) >>> discr.cell_sides array([ 0.1, 0.4])
If no additional argument is given, a copy of
discr
is returned:>>> odl.uniform_discr_fromdiscr(discr) == discr True >>> odl.uniform_discr_fromdiscr(discr) is discr False
Giving
min_pt
ormax_pt
results in a translation, while for the other two options, the domain is kept but re-partitioned:>>> odl.uniform_discr_fromdiscr(discr, min_pt=[1, 1]) uniform_discr([ 1., 1.], [ 2., 3.], (10, 5)) >>> odl.uniform_discr_fromdiscr(discr, max_pt=[0, 0]) uniform_discr([-1., -2.], [ 0., 0.], (10, 5)) >>> odl.uniform_discr_fromdiscr(discr, cell_sides=[1, 1]) uniform_discr([ 0., 0.], [ 1., 2.], (1, 2)) >>> odl.uniform_discr_fromdiscr(discr, shape=[5, 5]) uniform_discr([ 0., 0.], [ 1., 2.], (5, 5)) >>> odl.uniform_discr_fromdiscr(discr, shape=[5, 5]).cell_sides array([ 0.2, 0.4])
The cases with 2 or more additional arguments and the syntax for specifying quantities per axis is illustrated in the following:
# axis 0: translate to match max_pt = 3 # axis 1: recompute max_pt using the original shape with the # new min_pt and cell_sides >>> new_discr = odl.uniform_discr_fromdiscr(discr, min_pt=[None, 1], … max_pt=[3, None], … cell_sides=[None, 0.25]) >>> new_discr uniform_discr([ 2., 1.], [ 3. , 2.25], (10, 5)) >>> new_discr.cell_sides array([ 0.1 , 0.25])
# axis 0: recompute min_pt from old cell_sides and new # max_pt and shape # axis 1: use new min_pt, shape and cell_sides only >>> new_discr = odl.uniform_discr_fromdiscr(discr, min_pt=[None, 1], … max_pt=[3, None], … shape=[5, 5], … cell_sides=[None, 0.25]) >>> new_discr uniform_discr([ 2.5, 1. ], [ 3. , 2.25], (5, 5)) >>> new_discr.cell_sides array([ 0.1 , 0.25])