nifty8.operators.selection_operators module#

class SliceOperator(domain, new_shape, center=False, preserve_dist=True)[source]#

Bases: LinearOperator

Geometry preserving mask operator

Takes a field, slices it into the desired shape and returns the values of the field in the sliced domain all while preserving the original distances.

Parameters:
  • domain (Domain, DomainTuple or tuple of Domain) – The operator’s input domain.

  • new_shape (tuple of tuples or integers, or None) – The shape of the target domain with None indicating to copy the shape of the original domain for this axis. For example ((10, 5), 100) for a DomainTuple with two entires, the first having shape (10, 5) and the second having shape 100

  • center (bool, optional) – Whether to center the slice that is selected in the input field.

  • preserve_dist (bool, optional) – Whether to preserve the distance of the input field.

__init__(domain, new_shape, center=False, preserve_dist=True)[source]#
__str__()[source]#

Return str(self).

apply(x, mode)[source]#

Applies the Operator to a given x, in a specified mode.

Parameters:
  • x (nifty8.field.Field) – The input Field, defined on the Operator’s domain or target, depending on mode.

  • mode (int) –

    • TIMES: normal application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class SplitOperator(domain, slices_by_key, intersecting_slices=True)[source]#

Bases: LinearOperator

Split a single field into a multi-field

Takes a field, selects the desired entries for each multi-field key and puts the result into a multi-field. Along sliced axis, the domain will be replaced by an UnstructuredDomain as no distance measures are preserved.

Note, slices may intersect, i.e. slices may reference the same input multiple times if the intersecting_slices option is set. However, a single field in the output may not contain the same part of the input more than once.

Parameters:
  • domain (Domain, DomainTuple or tuple of Domain) – The operator’s input domain.

  • slices_by_key (dict{key: tuple of integers or None}) – The key-value pairs of which the values indicate the parts to be selected. The result will be a multi-field with the given keys as entries and the selected slices of the domain as values. None indicates to select the whole input along this axis.

  • intersecting_slices (bool, optional) – Tells the operator whether slices may contain intersections. If true, the adjoint is constructed a little less efficiently. Set this parameter to False to gain a little more efficiency.

__init__(domain, slices_by_key, intersecting_slices=True)[source]#
__str__()[source]#

Return str(self).

apply(x, mode)[source]#

Applies the Operator to a given x, in a specified mode.

Parameters:
  • x (nifty8.field.Field) – The input Field, defined on the Operator’s domain or target, depending on mode.

  • mode (int) –

    • TIMES: normal application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field